100mph on a docker-machine
Use multiple envidonments on your Local or Remote development with docker-machine
Prerequiments
- Oracle VirtualBox
- docker cli
- Available Disk Storage > 20GB
- Internet Connectivity :D
What is docker-machine
It allows you to control the docker engine of a VM created using docker-machine
remotely.
When you have a containerized application, it’s essential to quickly deploy them in the cloud, not only running them locally using Docker for Mac/Windows or from a Linux box locally. The tool to easily create a remote virtual machine (VM) and manage those containers is docker-machine.
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”.
How to create a docker-machine?
For more information, read the documentation on github.com/docker/machine
Create it using VirtualBox
|
|
You have a docker-machine VM; now what?
Most used commands
docker-machine ls
Show a list of docker-machinesdocker-machine ssh development
SSH access to the Machineeval $(docker-machine env development)
Enable current session with the Machinedocker-machine active
Shows the current Docker Machinedocker-machine ip development
Shows the current Machine’s IPdocker-machine scp ~/localfile.txt demo-machine:~/
SCP files into the Machinedocker-machine env -u
Go back to the local dockerdocker-machine rm development
Delete the Machine
Deploy a docker container in the Docker Machine
Docker CLI is looking for some default environment variables when it’s executed. When we create the docker-machine, we can export the variables for the docker-machine VM we wish.
Export ENV of a docker-machine
|
|
fter exporting the
After running this command or for a shorter time, you could have run eval $(docker-machine env development)
, which would have automatically exported the environment variables.
The End
After this we can run any docker commands towards the development
docker-machin siting on our local VM
When ready, to restore back to your “normal” local docker environment
|
|