DEV Community

Cover image for Docker machine: what is and the main commands
Igor Souto
Igor Souto

Posted on

Docker machine: what is and the main commands

Docker machine allows us to easily deploy an environment from a local machine in any infrastructure service, like AWS, DigitalOcean, Google Cloud, etc, through the installation of the driver that you want, environment variables, etc.

With that, we can create a host Docker in any of these platforms, and easily manage those machines from our local machine.

Main commands

CREATE

docker-machine create --driver virtualbox first-host-box
Enter fullscreen mode Exit fullscreen mode

This command, creates a new host docker, with the driver VirtualBox and with the name "first-host-box".

LS

docker-machine ls
Enter fullscreen mode Exit fullscreen mode

Lists all the available hosts in your machine.

ENV

Lists the environment variables that need to be set.

We can easily declare it with:

eval $(docker-machine env first-host-box)
Enter fullscreen mode Exit fullscreen mode

IP

docker-machine ip first-host-box
Enter fullscreen mode Exit fullscreen mode

Lists the ip of the host docker.

SSH

docker-machine ssh first-host-box
Enter fullscreen mode Exit fullscreen mode

With this command, we can access via SSH this host docker and use Linux commands inside it.

INSPECT

docker-machine inspect first-host-box
Enter fullscreen mode Exit fullscreen mode

Shows details of the host docker.

STOP

docker-machine stop first-host-box
Enter fullscreen mode Exit fullscreen mode

Stops the host.

START

docker-machine start first-host-box
Enter fullscreen mode Exit fullscreen mode

Starts the host.

RM

docker-machine rm first-host-box
Enter fullscreen mode Exit fullscreen mode

Removes the host.

Conclusion

With this, the Docker machine promotes great ease of installation and deployment in a cloud environment from its local containers.

Top comments (0)