Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Automatically set Docker env vars when opening a new Terminal on Mac OS X #261

Open
jsvisa opened this issue Mar 13, 2015 · 15 comments
Open

Comments

@jsvisa
Copy link

jsvisa commented Mar 13, 2015

I like this machine, but when I operate docker CLI directly in Terminal, it not worked with error:

FATA[0000] Get http:///var/run/docker.sock/v1.17/containers/json: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?

And when I follow the manual, It working.
image

How it would be joyful when I can directly operate docker in Terminal

@jmorganca jmorganca changed the title docker CLI not worked when directly pressed in Terminal Docker ENV variables not set when opening a new Terminal on Mac OS X Mar 14, 2015
@jmorganca
Copy link
Contributor

Thanks for the issue!

For now, if you don't use the above button, you'll need to type $(docker-machine env dev) when opening a terminal.

@jmorganca jmorganca changed the title Docker ENV variables not set when opening a new Terminal on Mac OS X Automatically set Docker ENV when opening a new Terminal on Mac OS X Mar 14, 2015
@jmorganca jmorganca changed the title Automatically set Docker ENV when opening a new Terminal on Mac OS X Automatically set Docker env vars when opening a new Terminal on Mac OS X Mar 14, 2015
@jsvisa
Copy link
Author

jsvisa commented Mar 15, 2015

Thanks for your advice, I customary add the following code to my .bash_profile or .bashrc file

export `docker-machine env dev`

@DieterReuter
Copy link

@jsvisa You could also change it to a more modern bash variant (don't use backticks anymore)

$(docker-machine env dev)

This can be use in a bash shell and works well in your .bashrc too.

@MichielDeMey
Copy link

I agree, setting these automatically would surely help out here.

@seanli
Copy link
Contributor

seanli commented Mar 26, 2015

Thanks for helping out @DieterReuter !

@jsvisa
Copy link
Author

jsvisa commented Mar 30, 2015

Thanks for @DieterReuter 👍

@lukehoersten
Copy link

Having this issue with the home-brew install but running $(docker-machine env dev) doesn't resolve the issue (see the linked home-brew issue above).

@jmorganca
Copy link
Contributor

@lukehoersten do you have Kitematic installed? Does ls /usr/local/bin/docker-machine exist?

Make sure there's a VM and it's running. If so, and you have docker installed, running docker-machine env dev | source should work on all shells

@lukehoersten
Copy link

My bad I didn't have a VM running. Thanks for the heads up.

@jmorganca
Copy link
Contributor

@lukehoersten No worries! Good to hear! 😃

@omarabid
Copy link

omarabid commented May 9, 2015

@JeffDM Why is this closed? No plans to have it fixed/automated through Kitematic?

@jmorganca
Copy link
Contributor

@omarabid It's not closed :-), though another Closed issue referenced this one 12 days ago

@omarabid
Copy link

@JeffDM ooups my bad. need more coffee.

@peteruithoven
Copy link

Actually http://docs.docker.com/machine/#env recommends using eval "$(docker-machine env dev)".

On my OS X computer the above mentioned command also better handles the comment, when I use $(docker-machine env dev) I get the following error:

-bash: export: `#': not a valid identifier
-bash: export: `shell:': not a valid identifier
-bash: export: `"$(docker-machine': not a valid identifier
-bash: export: `dev)"': not a valid identifier

Please mention this in the Kitematic docs somewhere, this is super useful information.

@jmorganca
Copy link
Contributor

@peteruithoven thanks! cc @SvenDowideit in case interesting 😃

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants