Monday, August 13, 2018

How to install Docker

Prerequisites

  • I'm using Windows8.

Install Docker toolbox for Windows

Get an installer for Docker toolbox from here: https://docs.docker.com/toolbox/toolbox_install_windows

Install Docker toolbox with the installer. Please don't forget to tick git for Windows if you don't have it. If you don't know what it is, tick it. If you already have virtualbox, you can untick virtualbox.

Use Docker toolbox

Double-click on the shortcut icon of Docker quick start terminal: 

 If you run it for the first time, it creates a virtual machine used for Docker engine on the Virtualbox. After that, you will login to the virtual machine. 

This message means a virtual machine called "default" is ready at IP:192.168.99.100. The IP address varies depending on the environment. From this virtual machine, you use Docker. To check if it really works, run this command on it:
$ docker run hello-world
If you see this, you successfully did it:
docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.
...

Commands of Docker

To create a virtual machine called "dev":
$ docker-machine create --driver virtualbox dev
To check all machines and their status:
$ docker-machine ls
To stop the virtual machine called dev:
$ docker-machine stop dev
To start the virtual machine called dev:
$ docker-machine start dev
To remove the virtual machine called dev:
$ docker-machine rm dev

Access the Docker via SSH connection

Check the IP to connect on the Docker toolbox:
$ docker-machine ip
192.168.99.100
You can use this IP to connect from Putty via SSH connection. The user name is "docker" and the password is "tcuser".

Shared folder

"C:\Users" in host windows machine is shared to "/c/Users" in guest machine by default. 

Stop the Docker's machine

You can stop the default machine by
$ docker-machine stop default