If you install Docker using the Docker Toolbox, the installer will automatically create a virtual machine for you. The virtual machine runs the Docker engine, the server part of Docker, and you can manage this virtual machine with the
docker-machine ls will give you a list of all your available machines.
Here, you see we have one Docker machine with the name “default”. The virtual machine for default Docker Machine runs on virtualbox. Virtualbox is a hypervisor, which was automatically installed by Docker Toolbox. Docker Machine allows you to perform basic operations like starting and stopping the virtual machine. For example, with
docker-machine start default or
Throughout this course, we will make heavy use of the Docker client. Docker client talks to the Docker engine, and since our Docker engine runs in a virtual machine here, we need to tell the Docker client how to communicate with it. Docker machine makes this step easy. With
docker-machine env followed by the name of the Docker machine, you get the commands you need to run to configure your Docker client. We could simply copy and paste the commands right here, or you execute this command (
eval $(docker-machine env default)), which will do that automatically.
The commands might look different on your machine depending on the shell and operating system you're using. Once you configure the client, you should be able to run
docker-machine active to see which Docker machine you're talking to. If this looks good, run
docker version. This will give you information about the Docker client and the server or Docker engine.
Depending on your setup you might have to run
docker-machine env default every time you open your terminal. Otherwise, the Docker client might try to talk to a Docker engine that runs on your local system. Use the
docker-machine active and
docker version commands to verify that you can talk to your Docker engine.
In this course we will talk to services that run in containers and we often access those services using localhost. However, your containers will run in a virtual machine. That means you will have to replace localhost with the IP address of your Docker machine. You can get this information with
docker-machine ip default.
If you're using a Docker machine, you have to replace localhost with the IP address of your Docker machine. Don't forget to use the
docker-machine env command to configure your Docker client.