Docker

From BITPlan profiwiki Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Tool
name  Docker
logo  DockerLogo.png
logourl  logo.png
website  https://www.docker.com/
wikipediaurl  https://en.wikipedia.org/wiki/Docker_%28software%29
stackoverflow link  http://stackoverflow.com/questions/tagged/docker
no of stackoverflow questions  49,616
Category  Build
pollResult  


Virtual Machine versus Container

MJHfm1c.jpg

Introduction to Docker by Solomon Hykes

  • Shipping code to the server is too hard
  • Docker uses separation of concerns (just like the Y-principle) to make shipping easier
  • Docker images are manipulated git style with ids, diffs, commits, pushs and pulls

Links

Installation

Installation of Docker on Mac OS X

  1. Download Docker Toolbox
  2. Install (e.g. DockerToolbox-1.8.3.pkg)
  3. Either Use Kitematic Visual Management for Docker or Docker Quickstart Terminal Command Line Interface

Clipboard20151017102651.png

                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/


docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com

Installation of Docker on Linux

Docker command examples

upgrade docker machine

docker-machine upgrade default

list running docker processes

bash-3.2$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

get and start the latest ubuntu image

docker run ubuntu

see which images are available

bash-3.2$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ubuntu              latest              0a17decee413        4 days ago          188.4 MB
bash-3.2$ 

start a bash shall in ubuntu

docker run -i -t ubuntu /bin/bash

modify the image by creating new directory

root@84506e084bb9:/#touch /test

look at processes again and check the difference of the image with the given container id

bash-3.2$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
84506e084bb9        ubuntu              "/bin/bash"         2 minutes ago       Up 2 minutes                            pensive_wozniak
bash-3.2$ docker diff 84506e084bb9
A /test

install some software

root@84506e084bb9:/#apt-get install php5
root@84506e084bb9:/#apt-get install mysql-server

commit the changes to images with the name "lamp" and check the image list again

bash-3.2$ docker commit 84506e084bb9 lamp
8ba719cd9b0eae589b70f6b6ddd567b4c20f997fc2d8f4c6feb313d73c2d5c3a

bash-3.2$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
lamp                latest              8ba719cd9b0e        20 seconds ago      349.5 MB
ubuntu              latest              0a17decee413        4 days ago          188.4 MB
bash-3.2$
docker version
Client:
 Version:      1.8.3
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   f4bf5c7
 Built:        Mon Oct 12 18:01:15 UTC 2015
 OS/Arch:      darwin/amd64

Server:
 Version:      1.8.3
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   f4bf5c7
 Built:        Mon Oct 12 18:01:15 UTC 2015
 OS/Arch:      linux/amd64

Useful scripts

Docker goodies

Static content example

Use the nginx image from https://github.com/docker-library/docs/tree/master/nginx

docker run --name icon_html -v /Users/wf/Documents/workspace/com.bitplan.icons/src/main/resources/com/bitplan/icons:/usr/share/nginx/html:ro -d -p 8080:80 nginx

find out the ip address for the mapping (Mac OS X)

docker-machine env default
export DOCKER_HOST="tcp://192.168.99.100:2376"

try out via

http://192.168.99.100:8080/48x48/shadow/wrench.png

wrench.png

Dockerfile

The process can be automated using a Dockerfile

Critics

Docker book

load PDF