Skip to content

Commit 8d3471f

Browse files
committed
Rename variable used for defining used docker.sock file
#174 added an experimental "rootless" variant of the DinD service. While the change itself is simple and should not affect current usages, a `DOCKER_HOST` variable was used to define which docker.sock path should be used depending on the process owner's ID. Chosing DOCKER_HOST variable for this is unfortunately not the best option: 1. It's not the best semantic choice - the code that uses it defines a socket file, not the host. DOCKER_SOCKET just seems to fit better the purpose. 1. DOCKER_HOST is already a variable, that is used by users to define where the Docker daemon is listening. In case when it's added to the DinD container (which is a common situation for example for GitLab CI jobs that are using DinD as a service), it finally ends with assigning two times the same port, while once it uses 0.0.0.0 address, and once some unresolvable domain name (depending on what user defined; most probably `docker`). This commit proposes a change of the variable name to DOCKER_SOCKET, which will better match it purpose and additionally it will stop breaking configurations of many of docker:dind image users. Signed-off-by: Tomasz Maczukin <tomasz@maczukin.pl>
1 parent 2285205 commit 8d3471f

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

18.09-rc/dind/dockerd-entrypoint.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ _tls_generate_certs() {
9292
# no arguments passed
9393
# or first arg is `-f` or `--some-option`
9494
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
95-
# set DOCKER_HOST to the default "--host" value (for both standard or rootless)
95+
# set DOCKER_SOCKET to the default "--host" value (for both standard or rootless)
9696
uid="$(id -u)"
9797
if [ "$uid" = '0' ]; then
98-
: "${DOCKER_HOST:=unix:///var/run/docker.sock}"
98+
: "${DOCKER_SOCKET:=unix:///var/run/docker.sock}"
9999
else
100100
# if we're not root, we must be trying to run rootless
101101
: "${XDG_RUNTIME_DIR:=/run/user/$uid}"
102-
: "${DOCKER_HOST:=unix://$XDG_RUNTIME_DIR/docker.sock}"
102+
: "${DOCKER_SOCKET:=unix://$XDG_RUNTIME_DIR/docker.sock}"
103103
fi
104-
export DOCKER_HOST
104+
export DOCKER_SOCKET
105105

106106
# add our default arguments
107107
if [ -n "${DOCKER_TLS_CERTDIR:-}" ] \
@@ -112,7 +112,7 @@ if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
112112
; then
113113
# generate certs and use TLS if requested/possible (default in 19.03+)
114114
set -- dockerd \
115-
--host="$DOCKER_HOST" \
115+
--host="$DOCKER_SOCKET" \
116116
--host=tcp://0.0.0.0:2376 \
117117
--tlsverify \
118118
--tlscacert "$DOCKER_TLS_CERTDIR/server/ca.pem" \
@@ -123,7 +123,7 @@ if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
123123
else
124124
# TLS disabled (-e DOCKER_TLS_CERTDIR='') or missing certs
125125
set -- dockerd \
126-
--host="$DOCKER_HOST" \
126+
--host="$DOCKER_SOCKET" \
127127
--host=tcp://0.0.0.0:2375 \
128128
"$@"
129129
DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS="${DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS:-} -p 0.0.0.0:2375:2375/tcp"

18.09/dind/dockerd-entrypoint.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ _tls_generate_certs() {
9292
# no arguments passed
9393
# or first arg is `-f` or `--some-option`
9494
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
95-
# set DOCKER_HOST to the default "--host" value (for both standard or rootless)
95+
# set DOCKER_SOCKET to the default "--host" value (for both standard or rootless)
9696
uid="$(id -u)"
9797
if [ "$uid" = '0' ]; then
98-
: "${DOCKER_HOST:=unix:///var/run/docker.sock}"
98+
: "${DOCKER_SOCKET:=unix:///var/run/docker.sock}"
9999
else
100100
# if we're not root, we must be trying to run rootless
101101
: "${XDG_RUNTIME_DIR:=/run/user/$uid}"
102-
: "${DOCKER_HOST:=unix://$XDG_RUNTIME_DIR/docker.sock}"
102+
: "${DOCKER_SOCKET:=unix://$XDG_RUNTIME_DIR/docker.sock}"
103103
fi
104-
export DOCKER_HOST
104+
export DOCKER_SOCKET
105105

106106
# add our default arguments
107107
if [ -n "${DOCKER_TLS_CERTDIR:-}" ] \
@@ -112,7 +112,7 @@ if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
112112
; then
113113
# generate certs and use TLS if requested/possible (default in 19.03+)
114114
set -- dockerd \
115-
--host="$DOCKER_HOST" \
115+
--host="$DOCKER_SOCKET" \
116116
--host=tcp://0.0.0.0:2376 \
117117
--tlsverify \
118118
--tlscacert "$DOCKER_TLS_CERTDIR/server/ca.pem" \
@@ -123,7 +123,7 @@ if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
123123
else
124124
# TLS disabled (-e DOCKER_TLS_CERTDIR='') or missing certs
125125
set -- dockerd \
126-
--host="$DOCKER_HOST" \
126+
--host="$DOCKER_SOCKET" \
127127
--host=tcp://0.0.0.0:2375 \
128128
"$@"
129129
DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS="${DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS:-} -p 0.0.0.0:2375:2375/tcp"

19.03-rc/dind/dockerd-entrypoint.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ _tls_generate_certs() {
9292
# no arguments passed
9393
# or first arg is `-f` or `--some-option`
9494
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
95-
# set DOCKER_HOST to the default "--host" value (for both standard or rootless)
95+
# set DOCKER_SOCKET to the default "--host" value (for both standard or rootless)
9696
uid="$(id -u)"
9797
if [ "$uid" = '0' ]; then
98-
: "${DOCKER_HOST:=unix:///var/run/docker.sock}"
98+
: "${DOCKER_SOCKET:=unix:///var/run/docker.sock}"
9999
else
100100
# if we're not root, we must be trying to run rootless
101101
: "${XDG_RUNTIME_DIR:=/run/user/$uid}"
102-
: "${DOCKER_HOST:=unix://$XDG_RUNTIME_DIR/docker.sock}"
102+
: "${DOCKER_SOCKET:=unix://$XDG_RUNTIME_DIR/docker.sock}"
103103
fi
104-
export DOCKER_HOST
104+
export DOCKER_SOCKET
105105

106106
# add our default arguments
107107
if [ -n "${DOCKER_TLS_CERTDIR:-}" ] \
@@ -112,7 +112,7 @@ if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
112112
; then
113113
# generate certs and use TLS if requested/possible (default in 19.03+)
114114
set -- dockerd \
115-
--host="$DOCKER_HOST" \
115+
--host="$DOCKER_SOCKET" \
116116
--host=tcp://0.0.0.0:2376 \
117117
--tlsverify \
118118
--tlscacert "$DOCKER_TLS_CERTDIR/server/ca.pem" \
@@ -123,7 +123,7 @@ if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
123123
else
124124
# TLS disabled (-e DOCKER_TLS_CERTDIR='') or missing certs
125125
set -- dockerd \
126-
--host="$DOCKER_HOST" \
126+
--host="$DOCKER_SOCKET" \
127127
--host=tcp://0.0.0.0:2375 \
128128
"$@"
129129
DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS="${DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS:-} -p 0.0.0.0:2375:2375/tcp"

19.03/dind/dockerd-entrypoint.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ _tls_generate_certs() {
9292
# no arguments passed
9393
# or first arg is `-f` or `--some-option`
9494
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
95-
# set DOCKER_HOST to the default "--host" value (for both standard or rootless)
95+
# set DOCKER_SOCKET to the default "--host" value (for both standard or rootless)
9696
uid="$(id -u)"
9797
if [ "$uid" = '0' ]; then
98-
: "${DOCKER_HOST:=unix:///var/run/docker.sock}"
98+
: "${DOCKER_SOCKET:=unix:///var/run/docker.sock}"
9999
else
100100
# if we're not root, we must be trying to run rootless
101101
: "${XDG_RUNTIME_DIR:=/run/user/$uid}"
102-
: "${DOCKER_HOST:=unix://$XDG_RUNTIME_DIR/docker.sock}"
102+
: "${DOCKER_SOCKET:=unix://$XDG_RUNTIME_DIR/docker.sock}"
103103
fi
104-
export DOCKER_HOST
104+
export DOCKER_SOCKET
105105

106106
# add our default arguments
107107
if [ -n "${DOCKER_TLS_CERTDIR:-}" ] \
@@ -112,7 +112,7 @@ if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
112112
; then
113113
# generate certs and use TLS if requested/possible (default in 19.03+)
114114
set -- dockerd \
115-
--host="$DOCKER_HOST" \
115+
--host="$DOCKER_SOCKET" \
116116
--host=tcp://0.0.0.0:2376 \
117117
--tlsverify \
118118
--tlscacert "$DOCKER_TLS_CERTDIR/server/ca.pem" \
@@ -123,7 +123,7 @@ if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
123123
else
124124
# TLS disabled (-e DOCKER_TLS_CERTDIR='') or missing certs
125125
set -- dockerd \
126-
--host="$DOCKER_HOST" \
126+
--host="$DOCKER_SOCKET" \
127127
--host=tcp://0.0.0.0:2375 \
128128
"$@"
129129
DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS="${DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS:-} -p 0.0.0.0:2375:2375/tcp"

dockerd-entrypoint.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ _tls_generate_certs() {
9292
# no arguments passed
9393
# or first arg is `-f` or `--some-option`
9494
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
95-
# set DOCKER_HOST to the default "--host" value (for both standard or rootless)
95+
# set DOCKER_SOCKET to the default "--host" value (for both standard or rootless)
9696
uid="$(id -u)"
9797
if [ "$uid" = '0' ]; then
98-
: "${DOCKER_HOST:=unix:///var/run/docker.sock}"
98+
: "${DOCKER_SOCKET:=unix:///var/run/docker.sock}"
9999
else
100100
# if we're not root, we must be trying to run rootless
101101
: "${XDG_RUNTIME_DIR:=/run/user/$uid}"
102-
: "${DOCKER_HOST:=unix://$XDG_RUNTIME_DIR/docker.sock}"
102+
: "${DOCKER_SOCKET:=unix://$XDG_RUNTIME_DIR/docker.sock}"
103103
fi
104-
export DOCKER_HOST
104+
export DOCKER_SOCKET
105105

106106
# add our default arguments
107107
if [ -n "${DOCKER_TLS_CERTDIR:-}" ] \
@@ -112,7 +112,7 @@ if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
112112
; then
113113
# generate certs and use TLS if requested/possible (default in 19.03+)
114114
set -- dockerd \
115-
--host="$DOCKER_HOST" \
115+
--host="$DOCKER_SOCKET" \
116116
--host=tcp://0.0.0.0:2376 \
117117
--tlsverify \
118118
--tlscacert "$DOCKER_TLS_CERTDIR/server/ca.pem" \
@@ -123,7 +123,7 @@ if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
123123
else
124124
# TLS disabled (-e DOCKER_TLS_CERTDIR='') or missing certs
125125
set -- dockerd \
126-
--host="$DOCKER_HOST" \
126+
--host="$DOCKER_SOCKET" \
127127
--host=tcp://0.0.0.0:2375 \
128128
"$@"
129129
DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS="${DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS:-} -p 0.0.0.0:2375:2375/tcp"

0 commit comments

Comments
 (0)