« Back to projectatomic.io
Ask Your Question

Passing in environment variables?

asked 2015-09-17 15:19:11 +0000

xaeth gravatar image

updated 2015-09-17 15:19:54 +0000

I'm working on a docker image that needs to have the SSH_AUTH_SOCK env variable referenced in the docker command when run. When atomic runs the command, it is empty.

$ sudo atomic run --name=test rspec-puppet:puppet3 
[sudo] password: 
docker run -t --name test -v /home/me//puppet/module:/module:z -v :/ssh-agent:z -e SSH_AUTH_SOCK=/ssh-agent rspec-puppet:puppet3
invalid value ":/ssh-agent:z" for flag -v: bad format for volumes: :/ssh-agent:z
See 'docker run --help'.

I am running this through sudo, but I have sudo passing keeping the variable in my environment, and checking that works fine.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-09-17 20:21:19 +0000

Have you looked at using the opt* variables for atomic? You should be able to pass the value of from the shell ENV value into the docker run line like this:

LABEL RUN="docker run -t --name NAME -v \$(pwd):/module:z -v \${OPT1}:/ssh-agent:z -e SSH_AUTH_SOCK=\${OPT1} IMAGE"

sudo atomic run --name=test --opt1=$SSH_AUTH_SOCK rspec-puppet:puppet3

That would let you be flexible in the container spec and on the commandline to pick up the right shell ENV value.

I did a trivial test and came up with this:

export SSH_AUTH_SOCK=larry
sudo atomic run --name=test --opt1=$SSH_AUTH_SOCK 653c1bd4db1e
docker run -t --name test -v /var/home/fedora/rspec:/module:z -v larry:/ssh-agent:z -e SSH_AUTH_SOCK=larry 653c1bd4db1e

which looks like what you want using that LABEL construction.

edit flag offensive delete link more


That definitely works, and its better than the whole command, but still makes me sad

xaeth ( 2015-09-18 17:21:54 +0000 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

1 follower


Asked: 2015-09-17 15:19:11 +0000

Seen: 581 times

Last updated: Sep 17 '15