Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic TLS generation (and enable it by default in 19.03+) #166

Merged
merged 1 commit into from
Jul 17, 2019

Conversation

tianon
Copy link
Member

@tianon tianon commented Jul 17, 2019

Closes #164
Refs docker-library/docs#1525

This adds a DOCKER_TLS_CERTDIR environment variable that, when present, will auto-enable TLS on dockerd by default (and will set the appropriate client flags if the necessary certificates exist).

It will attempt to generate a suitable subjectAltName extension value based on all available container IP addresses and hostnames, but the default generation can be extended via the DOCKER_TLS_SAN environment variable (in the standard OpenSSL format, ala IP:n.n.n.n,DNS:foobar,...).

For users of 18.09 who wish to enable this behavior, simply set DOCKER_TLS_CERTDIR to a path within the container into which you want certificates generated (and share at least the client subdirectory of that path with your client containers). The default value in 19.03+ is /certs (so to mimic that, something like -e DOCKER_TLS_CERTDIR=/certs would be sufficient/appropriate).

For users of 19.03+ who wish to disable this behavior (not recommended), simply set DOCKER_TLS_CERTDIR to the empty string (-e DOCKER_TLS_CERTDIR=).

tianon added a commit to docker-library/official-images that referenced this pull request Jul 17, 2019
For images which don't support this feature, this will be a no-op.
@tianon
Copy link
Member Author

tianon commented Jul 17, 2019

Test updated in docker-library/official-images@7e44f39 👍

@tianon
Copy link
Member Author

tianon commented Jul 17, 2019

(We should probably also add a new docker-dind-insecure test that just does the basics to verify DOCKER_TLS_CERTDIR= works to disable this.)

@tianon
Copy link
Member Author

tianon commented Jul 17, 2019

(dat +529 −40 tho 😭)

19.03-rc/Dockerfile Outdated Show resolved Hide resolved
[ -z "${DOCKER_TLS_SAN:-}" ] || echo "$DOCKER_TLS_SAN"
} | sort -u | xargs printf '%s,' | sed "s/,\$//"
}
_tls_generate_certs() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any chance to split this to a separate script so that it can be called from rootless entrypoint script? #165

This adds a `DOCKER_TLS_CERTDIR` environment variable that, when present, will auto-enable TLS on `dockerd` by default (and will set the appropriate client flags if the necessary certificates exist).

It will attempt to generate a suitable `subjectAltName` extension value based on all available container IP addresses and hostnames, but the default generation can be extended via the `DOCKER_TLS_SAN` environment variable (in the standard OpenSSL format, ala `IP:n.n.n.n,DNS:foobar,...`).

For users of 18.09 who wish to enable this behavior, simply set `DOCKER_TLS_CERTDIR` to a path within the container into which you want certificates generated (and share at least the `client` subdirectory of that path with your client containers). The default value in 19.03+ is `/certs` (so to mimic that, something like `-e DOCKER_TLS_CERTDIR=/certs` would be sufficient/appropriate).

For users of 19.03+ who wish to *disable* this behavior (not recommended), simply set `DOCKER_TLS_CERTDIR` to the empty string (`-e DOCKER_TLS_CERTDIR=`).
@yosifkit yosifkit merged commit cad4d26 into docker-library:master Jul 17, 2019
@yosifkit yosifkit deleted the auto-tls branch July 17, 2019 23:34
@AkihiroSuda
Copy link
Contributor

opened #168 for splitting tls script

docker-library-bot added a commit to docker-library-bot/official-images that referenced this pull request Jul 18, 2019
Changes:

- docker-library/docker@cad4d26: Merge pull request docker-library/docker#166 from infosiftr/auto-tls
- docker-library/docker@651c075: Merge pull request docker-library/docker#167 from infosiftr/simpler-dind-example
@tianon
Copy link
Member Author

tianon commented Jul 19, 2019

Documentation PR is now open at docker-library/docs#1538 👍

no-reply pushed a commit to surfliner/surfliner-mirror that referenced this pull request Jul 24, 2019
Docker added a new TLS cert option in v19+, which is breaking dind usage
in pipelines. This disables the 'auto-enable TLS' feature.

see:
- docker-library/docker#166
- https://gitlab.com/gitlab-com/gl-infra/production/issues/982
- https://gitlab.com/gitlab-org/gitlab-ce/issues/64968
thaJeztah added a commit to thaJeztah/cli that referenced this pull request Jul 29, 2019
The docker-in-docker image now enables TLS by default (added in
docker-library/docker#166), which complicates testing in our
environment, and isn't needed for the tests we're running.

This patch sets the `DOCKER_TLS_CERTDIR` to an empty value to
disable TLS.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
thaJeztah added a commit to thaJeztah/cli that referenced this pull request Jul 29, 2019
The docker-in-docker image now enables TLS by default (added in
docker-library/docker#166), which complicates testing in our
environment, and isn't needed for the tests we're running.

This patch sets the `DOCKER_TLS_CERTDIR` to an empty value to
disable TLS.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit b1a3c1a)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
thaJeztah added a commit to thaJeztah/cli that referenced this pull request Jul 29, 2019
The docker-in-docker image now enables TLS by default (added in
docker-library/docker#166), which complicates testing in our
environment, and isn't needed for the tests we're running.

This patch sets the `DOCKER_TLS_CERTDIR` to an empty value to
disable TLS.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit b1a3c1a)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
thaJeztah added a commit to thaJeztah/cli that referenced this pull request Jul 30, 2019
The docker-in-docker image now enables TLS by default (added in
docker-library/docker#166), which complicates testing in our
environment, and isn't needed for the tests we're running.

This patch sets the `DOCKER_TLS_CERTDIR` to an empty value to
disable TLS.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit b1a3c1a)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
thaJeztah added a commit to thaJeztah/cli that referenced this pull request Jul 30, 2019
The docker-in-docker image now enables TLS by default (added in
docker-library/docker#166), which complicates testing in our
environment, and isn't needed for the tests we're running.

This patch sets the `DOCKER_TLS_CERTDIR` to an empty value to
disable TLS.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit b1a3c1a)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
docker-jenkins pushed a commit to docker-archive/docker-ce that referenced this pull request Jul 30, 2019
The docker-in-docker image now enables TLS by default (added in
docker-library/docker#166), which complicates testing in our
environment, and isn't needed for the tests we're running.

This patch sets the `DOCKER_TLS_CERTDIR` to an empty value to
disable TLS.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Upstream-commit: b1a3c1aad1d802975af11c16fce1177f09d1d97e
Component: cli
docker-jenkins pushed a commit to docker-archive/docker-ce that referenced this pull request Aug 8, 2019
The docker-in-docker image now enables TLS by default (added in
docker-library/docker#166), which complicates testing in our
environment, and isn't needed for the tests we're running.

This patch sets the `DOCKER_TLS_CERTDIR` to an empty value to
disable TLS.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit b1a3c1aad1d802975af11c16fce1177f09d1d97e)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Upstream-commit: 9c8ac0a1233944b0b3929bb34edc66d27c290293
Component: cli
docker-jenkins pushed a commit to docker-archive/docker-ce that referenced this pull request Aug 8, 2019
The docker-in-docker image now enables TLS by default (added in
docker-library/docker#166), which complicates testing in our
environment, and isn't needed for the tests we're running.

This patch sets the `DOCKER_TLS_CERTDIR` to an empty value to
disable TLS.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit b1a3c1aad1d802975af11c16fce1177f09d1d97e)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Upstream-commit: f357def0361cc2ae5f101ac95dff486ba4cd86c2
Component: cli
imrehg pushed a commit to balena-os/meta-balena that referenced this pull request Aug 9, 2019
The `docker` Docker Hub repository lists what versions of the image
are supported and 18.6 is not among them at all. Use the current stable
line of 18.09 instead, to stay on supported versions. See more info at:
https://hub.docker.com/_/docker

Also add a required parameter to run images from 18.09.8-dind onwards,
due to this change: docker-library/docker#166

Change-type: minor
Signed-off-by: Gergely Imreh <[email protected]>
imrehg pushed a commit to balena-os/meta-balena that referenced this pull request Aug 9, 2019
The `docker` Docker Hub repository lists what versions of the image
are supported and 18.6 is not among them at all. Use the current stable
line of 18.09 instead, to stay on supported versions. See more info at:
https://hub.docker.com/_/docker

Also add a required parameter to run images from 18.09.8-dind onwards,
due to this change: docker-library/docker#166
Here in effect disabling AutoTLS for the moment (TLS communication
with the daemon) since it's all local anyways.

Change-type: minor
Signed-off-by: Gergely Imreh <[email protected]>
imrehg pushed a commit to balena-os/meta-balena that referenced this pull request Aug 9, 2019
The `docker` Docker Hub repository lists what versions of the image
are supported and 18.6 is not among them at all. Use the current stable
line of 18.09 instead, to stay on supported versions. See more info at:
https://hub.docker.com/_/docker

Also add a required parameter to run images from 18.09.8-dind onwards,
due to this change: docker-library/docker#166

Update the test checking for docker being up, too.

Change-type: minor
Signed-off-by: Gergely Imreh <[email protected]>
imrehg pushed a commit to balena-os/meta-balena that referenced this pull request Aug 9, 2019
The `docker` Docker Hub repository lists what versions of the image
are supported and 18.6 is not among them at all. Use the current stable
line of 18.09 instead, to stay on supported versions. See more info at:
https://hub.docker.com/_/docker

Also added `DOCKER_HOST` as it affects `v18.09.8-dind` (which is trying
to use tcp socket instead, it seems: docker-library/docker#175
after it enabled AutoTLS in docker-library/docker#166

Change-type: minor
Signed-off-by: Gergely Imreh <[email protected]>
ruzanowski added a commit to ruzanowski/Ubiquitous that referenced this pull request Jul 2, 2020
  - name: docker:dind
    entrypoint: ["env", "-u", "DOCKER_HOST"]
    command: ["dockerd-entrypoint.sh"]
  variables:
    DOCKER_HOST: tcp://docker:2375/
    DOCKER_DRIVER: overlay2
    # See docker-library/docker#166
    DOCKER_TLS_CERTDIR: ""
ruzanowski added a commit to ruzanowski/Ubiquitous that referenced this pull request Jul 2, 2020
  - name: docker:dind
    entrypoint: ["env", "-u", "DOCKER_HOST"]
    command: ["dockerd-entrypoint.sh"]
  variables:
    DOCKER_HOST: tcp://docker:2375/
    DOCKER_DRIVER: overlay2
    # See docker-library/docker#166
    DOCKER_TLS_CERTDIR: ""
ruzanowski added a commit to ruzanowski/Ubiquitous that referenced this pull request Jul 2, 2020
  - name: docker:dind
    entrypoint: ["env", "-u", "DOCKER_HOST"]
    command: ["dockerd-entrypoint.sh"]
  variables:
    DOCKER_HOST: tcp://docker:2375/
    DOCKER_DRIVER: overlay2
    # See docker-library/docker#166
    DOCKER_TLS_CERTDIR: ""
paulgirard added a commit to medialab/toflit18_data that referenced this pull request Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate TLS on boot
3 participants