Docker

An open platform for distributed applications

Information
Docker (日本語)

Install on Arch Linux
# pacman -S docker

# systemctl start docker

docker を通常ユーザーで実行できるようにする

# gpasswd -a uchida docker

確認
$ export http_proxy=""
$ export NO_PROXY="/var/run/docker.sock"
$ docker version
$ docker info
/usr/lib/systemd/system/docker.service

Environment="http_proxy=http://user:passwd@host_proxy:80/"
$ docker pull ubuntu:latest

ubuntu:latest: The image you are pulling has been verified
511136ea3c5a: Pull complete 
53f858aaaf03: Pull complete 
837339b91538: Pull complete 
615c102e2290: Pull complete 
b39b81afc8ca: Pull complete 
Status: Downloaded newer image for ubuntu:latest
	
$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ubuntu              latest              c4ff7513909d        7 days ago          213 MB
	
ubuntuイメージからubuntu1コンテナーを作成、端末を開きbashを実行

$ docker run -it --name ubuntu1 ubuntu /bin/bash

再実行

$ docker start -i ubuntu1

コンテナーの一覧を確認

$ docker ps -a

	CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
aed97425cbd0        ubuntu:latest       "/bin/bash"         17 minutes ago      Up 4 minutes                            ubuntu1        
	
$ docker commit ubuntu1 uchida/nginx

$ docker run -it --name nginx2 uchida/nginx /bin/bash

停止した nginx2 コンテナで再度bashを実行する場合

# docker start -i nginx2


ホストで、ルートの設定

# route add -net 172.17.0.0/16 gw 172.17.42.1

$ docker pull fedora:latest

Fedora on Docker

Nginx on Docker


Install on Ubuntu

Dockerのインストールと主なコマンドの使い方

# apt-get install docker.io

# update-rc.d docker.io defaults

# docker info

Containers: 2
 Running: 0
 Paused: 0
 Stopped: 2
Images: 1
Server Version: 1.12.6
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 9
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: null host bridge overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: apparmor seccomp
Kernel Version: 4.10.0-20-generic
Operating System: Ubuntu 17.04
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 3.755 GiB
Name: iwata
ID: 6YRX:UKOF:UQJB:PWZJ:G4F2:SMYP:QKW6:Z4RM:J7TP:KA4D:P4IB:AOBU
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Insecure Registries:
 127.0.0.0/8
# docker version

Client:
 Version:      17.06.0-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   3dfb8343
 Built:        Wed Jul 26 18:03:33 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.06.0-ce
 API version:  1.30 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   02c1d87617
 Built:        Wed Jul 26 20:03:39 2017
 OS/Arch:      linux/amd64
 Experimental: false
# gpasswd -a uchida docker

/etc/default/docker

export http_proxy="http://user:password@server_proxy:80"

export https_proxy="http://user:password@server_proxy:80"


Vagrantでは構成情報を記述した設定ファイルを用意して簡単なコマンドを実行するだけで、仮想ディスクイメージのダウンロード、仮想マシンの作成や起動、そしてプロビジョニング用のコマンドの発行といったタスクを実行できる

Install

# packman -S vagrant

# packman -S virtualbox

# pacman -S virtualbox-host-modules

$ vagrant init

$ vagrant up


# docker rm `docker ps -a -q`


コンテナーの一覧
# docker ps

# docker ps -a


# docker run ubuntu cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"
Return

Aug/03/2017 AM 08:15