Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!

Docker environment variables on Mac

When we are using Docker with our operation system to the difference of Linux, we have to create a virtual machine using Virtualbox or Vmware and export the environment variables, the command to export the variables is this one:

eval "$(docker-machine env default)"

The command should be executed every time that the virtual machine with Linux is running, or we can add a command to our shell configuration to execute the command on a new shell session, if you are using bash you should add the next lines to ~/.bashrc if you are using zsh to ~/.zshrc:

docker_running=$(docker-machine ls | grep default)
if [[ "$docker_running" == *"Running"* ]]
  eval "$(docker-machine env default)"

In this case, the virtual machine name is default.