@@ -31,7 +31,7 @@ add your desired keys to it.
31
31
# Agent will need to be restarted and have key(s) re-added to it any time your
32
32
# docker host is restarted.
33
33
#
34
- version: '2.1 '
34
+ version: '3.2 '
35
35
36
36
services:
37
37
# use via docker-compose -f ssh.yml up [-d] ssh-agent
@@ -42,7 +42,6 @@ services:
42
42
- ssh:/ssh
43
43
44
44
# 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
46
45
ssh-add:
47
46
image: whilp/ssh-agent:latest
48
47
entrypoint: [ "ssh-add" ]
@@ -59,27 +58,37 @@ volumes:
59
58
Any container you want to connect to the SSH agent needs to set the environmental
60
59
variable SSH_AUTH_SOCK to /ssh/auth/sock and mount the ssh volume at path /ssh.
61
60
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.
64
70
65
71
```
66
- build.ssh.yml
72
+ # ssh.overrides.yml
73
+
67
74
version: '2.1'
68
75
69
76
services:
77
+ cli:
78
+ volumes:
79
+ - ssh:/ssh
80
+ environment:
81
+ SSH_AUTH_SOCK: /ssh/auth/sock
70
82
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
78
85
environment:
79
86
SSH_AUTH_SOCK: /ssh/auth/sock
87
+ volumes:
88
+ ssh:
80
89
```
81
90
82
91
### More Resources
83
92
84
- Additional information, including ways to have non root container processes access
93
+ Additional information, including ways to have non- root container processes access
85
94
the authorization socket can be found in the [ whilp/ssh-agent README] ( https://github.com/whilp/ssh-agent ) image.
0 commit comments