What’s the difference between Docker Engine and Docker Machine?
When people say “Docker” they typically mean Docker Engine, the client-server application made up of the Docker daemon, a REST API that specifies interfaces for interacting with the daemon, and a command line interface (CLI) client that talks to the daemon (through the REST API wrapper). Docker Engine accepts docker
commands from the CLI, such as docker run <image>
, docker ps
to list running containers, docker image ls
to list images, and so on.
Docker Machine is a tool for provisioning and managing your Dockerized hosts (hosts with Docker Engine on them). Typically, you install Docker Machine on your local system. Docker Machine has its own command line client docker-machine
and the Docker Engine client, docker
. You can use Machine to install Docker Engine on one or more virtual systems. These virtual systems can be local (as when you use Machine to install and run Docker Engine in VirtualBox on Mac or Windows) or remote (as when you use Machine to provision Dockerized hosts on cloud providers). The Dockerized hosts themselves can be thought of, and are sometimes referred to as, managed “*machines*”.
IP
If you are using Docker Machine, you can get the manager IP with either docker-machine ls
or docker-machine ip <MACHINE-NAME>
— for example, docker-machine ip manager1
.
The tutorial uses manager1
: 192.168.99.100
.
How to Connect to Docker Daemon
Add a host without a driver
You can register an already existing docker host by passing the daemon url. With that, you can have the same workflow as on a host provisioned by docker-machine.
# testing
$ curl 192.168.18.140:2375/v1.38/containers/json
$ docker run hello-world
# via TCP
$ docker-machine create --driver none --url=tcp://192.168.18.1140:2375 default1
# via SSH
$ docker-machine create --driver none --url=ssh://192.168.18.10:31565 default4
If you want to set DOCKER_HOST by default so it always connects remotely you can export it in your ~/.bashrc file. Here’s an example of that as a 1 liner:
echo "export DOCKER_HOST=tcp://X.X.X.X:2375" >> ~/.bashrc && source ~/.bashrc
Refer to https://swsmile.info/post/docker-daemon/ for how to config Docker Daemon