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

Update dind example to connect to daemon using TCP+TLS #1932

Merged
merged 2 commits into from
Jan 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions examples/taskruns/dind-sidecar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ spec:
steps:
- image: docker
name: client
env:
# Connect to the sidecar over TCP, with TLS.
- name: DOCKER_HOST
value: tcp://localhost:2376
# Verify TLS.
- name: DOCKER_TLS_VERIFY
value: '1'
# Use the certs generated by the sidecar daemon.
- name: DOCKER_CERT_PATH
value: /certs/client
script: |
#!/usr/bin/env sh
# Run a Docker container.
Expand All @@ -24,20 +34,28 @@ spec:
# ...then run it!
docker run hello
volumeMounts:
- mountPath: /var/run/
name: dind-socket
- mountPath: /certs/client
name: dind-certs

sidecars:
# 18.09-dind seems to be the latest version of the image that works with
# this example. The next released image, 19.03-dind doesn't work.
- image: docker:18.09-dind
- image: docker:dind
name: server
securityContext:
privileged: true
env:
# Write generated certs to the path shared with the client.
- name: DOCKER_TLS_CERTDIR
value: /certs
volumeMounts:
- mountPath: /var/run/
name: dind-socket
- mountPath: /certs/client
name: dind-certs
# Wait for the dind daemon to generate the certs it will share with the
# client.
readinessProbe:
periodSeconds: 1
exec:
command: ['ls', '/certs/client/ca.pem']

volumes:
- name: dind-socket
- name: dind-certs
emptyDir: {}