Masatoshi Nishiguchi




Docker platform

A platform for developing, shipping and running apps, using container visualization technology.


                  - Docker daemon
CLIENT -------->  - Container
                  - Container
                  - Container

Containers and images

Registry (DockerHub)

repo       repo       repo            
  + image    + image    + image
  + image    + image    + image
  + image    + image    + image
Local    <--pull---  DockerHub
         ---push-->  + repo
                     + repo
                     + repo

Basic commands

# Run a command in a new container:
docker run -it IMAGE [COMMAND] [ARG...]   # Standard input / terminal
docker run -d  IMAGE [COMMAND] [ARG...]   # Detached running in the background
docker attach CONTAINER_ID
docker run -d -P IMAGE [COMMAND] [ARG...] # Detached running in the background, mapping ports

# List containers
docker ps -a                       

Hello world test:

$ docker run hello-world
$ docker ps -a

Running a command in the container:

$ docker run ubuntu:14.04 echo "Konnichiwa sekai"
Konnichiwa sekai

Running bash in the container:

$ docker run -it ubuntu:latest /bin/bash
root@3eff1b34173e:/# echo "Hello"
root@3eff1b34173e:/# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

# CTRL + P + Q: Close the terminal.
# exit:         Close the container.     

Running a web application container:

# Start the container in the background, with port mapping.
$ docker run -d -P tomcat:7

# Check the port.
$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED                  STATUS              PORTS                     NAMES
5c545a857282        tomcat:7            " run"   Less than a second ago   Up 6 seconds>8080/tcp   elated_lovelace

# Visit that IP + PORT on the host's browser.

Logging the standard output:

$ docker logs -f CONTAINER_ID



Vagrant provides easy to configure, reproducible, and portable work environments built on top of industry-standard technology and controlled by a single consistent workflow to help maximize the productivity and flexibility of you and your team.

Provisioners in Vagrant allow you to automatically install software, alter configurations, and more on the machine as part of the vagrant up process.

Once you or someone else creates a single Vagrantfile, you just need to vagrant up and everything is installed and configured for you to work.