Skip to content

Commit f95b13d

Browse files
author
Chris Johnson
committed
SSH Agent documentation updates in response to PR feedback
1 parent 1d7fb52 commit f95b13d

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

docs/common-tasks/ssh-keys-for-private-repos.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ add your desired keys to it.
3131
# Agent will need to be restarted and have key(s) re-added to it any time your
3232
# docker host is restarted.
3333
#
34-
version: '2.1'
34+
version: '3.2'
3535
3636
services:
3737
# use via docker-compose -f ssh.yml up [-d] ssh-agent
@@ -42,7 +42,6 @@ services:
4242
- ssh:/ssh
4343
4444
# use via docker-compose -f ssh.yml run --rm ssh-add $HOME/.ssh/name_of_desired_key
45-
# use as many times as needed to add the desired keys
4645
ssh-add:
4746
image: whilp/ssh-agent:latest
4847
entrypoint: [ "ssh-add" ]
@@ -59,27 +58,37 @@ volumes:
5958
Any container you want to connect to the SSH agent needs to set the environmental
6059
variable SSH_AUTH_SOCK to /ssh/auth/sock and mount the ssh volume at path /ssh.
6160

62-
Here is an example build.ssh.yml file which extends the build.yml file's base
63-
container and adds the ssh agent ability.
61+
Here is an example ssh.overrides.yml file which can be combined with the build.yml
62+
file's base container and adds the ssh agent ability. To use this file you would
63+
run `docker-compose -f build.yml -f ssh.overrides.yml run --rm DESIRED_SERVICE`
64+
65+
!!! note "Overrides and extends"
66+
Overrides do not carry through to services extending an overridden service.
67+
The example below demonstrates that one needs to define the override for each
68+
service where it should apply even though in a typical build.yml file
69+
the cli service is a descendant of the base service.
6470

6571
```
66-
build.ssh.yml
72+
# ssh.overrides.yml
73+
6774
version: '2.1'
6875
6976
services:
77+
cli:
78+
volumes:
79+
- ssh:/ssh
80+
environment:
81+
SSH_AUTH_SOCK: /ssh/auth/sock
7082
base:
71-
extends:
72-
file: build.yml
73-
service: base
74-
volumes_from:
75-
# note that this is using the container name so if you choose a different
76-
# one they must be kept in sync
77-
- container:ssh-agent
83+
volumes:
84+
- ssh:/ssh
7885
environment:
7986
SSH_AUTH_SOCK: /ssh/auth/sock
87+
volumes:
88+
ssh:
8089
```
8190

8291
### More Resources
8392

84-
Additional information, including ways to have non root container processes access
93+
Additional information, including ways to have non-root container processes access
8594
the authorization socket can be found in the [whilp/ssh-agent README](https://github.com/whilp/ssh-agent) image.

0 commit comments

Comments
 (0)