主にLinuxサーバー設定記録をメモします

インストール

# yum install --enablerepo=epel docker-io
# yum install --enablerepo=epel docker-io
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
epel/metalink                                            | 6.1 kB     00:00
 * base: www.ftp.ne.jp
 * epel: ftp.kddilabs.jp
 * extras: www.ftp.ne.jp
 * updates: www.ftp.ne.jp
epel                                                     | 4.4 kB     00:00
epel/primary_db                                          | 6.2 MB     00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package docker-io.x86_64 0:1.0.0-3.el6 will be installed
--> Processing Dependency: lxc for package: docker-io-1.0.0-3.el6.x86_64
--> Processing Dependency: libcgroup for package: docker-io-1.0.0-3.el6.x86_64
--> Running transaction check
---> Package libcgroup.x86_64 0:0.40.rc1-5.el6_5.1 will be installed
---> Package lxc.x86_64 0:0.9.0-2.el6 will be installed
--> Processing Dependency: liblxc.so.0()(64bit) for package: lxc-0.9.0-2.el6.x86_64
--> Running transaction check
---> Package lxc-libs.x86_64 0:0.9.0-2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package          Arch          Version                    Repository      Size
================================================================================
Installing:
 docker-io        x86_64        1.0.0-3.el6                epel           4.5 M
Installing for dependencies:
 libcgroup        x86_64        0.40.rc1-5.el6_5.1         updates        125 k
 lxc              x86_64        0.9.0-2.el6                epel            78 k
 lxc-libs         x86_64        0.9.0-2.el6                epel           116 k

Transaction Summary
================================================================================
Install       4 Package(s)

Total download size: 4.8 M
Installed size: 24 M
Is this ok [y/N]:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : libcgroup-0.40.rc1-5.el6_5.1.x86_64                          1/4
  Installing : lxc-libs-0.9.0-2.el6.x86_64                                  2/4
  Installing : lxc-0.9.0-2.el6.x86_64                                       3/4
  Installing : docker-io-1.0.0-3.el6.x86_64                                 4/4
  Verifying  : docker-io-1.0.0-3.el6.x86_64                                 1/4
  Verifying  : lxc-libs-0.9.0-2.el6.x86_64                                  2/4
  Verifying  : libcgroup-0.40.rc1-5.el6_5.1.x86_64                          3/4
  Verifying  : lxc-0.9.0-2.el6.x86_64                                       4/4

Installed:
  docker-io.x86_64 0:1.0.0-3.el6

Dependency Installed:
  libcgroup.x86_64 0:0.40.rc1-5.el6_5.1         lxc.x86_64 0:0.9.0-2.el6
  lxc-libs.x86_64 0:0.9.0-2.el6

Complete!

スタート

# /etc/init.d/docker start
Starting cgconfig service:                                 [  OK  ]
Starting docker:                                           [  OK  ]
# chkconfig docker on
# docker -v
Docker version 1.0.0, build 63fe64c/1.0.0

ネットワークが追加される

コンテナ内のネットワークはDHCPになる
# ifconfig
docker0   Link encap:Ethernet  HWaddr 22:8B:1E:6D:62:F9
          inet addr:172.17.42.1  Bcast:0.0.0.0  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:13779 errors:0 dropped:0 overruns:0 frame:0
          TX packets:27541 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:783997 (765.6 KiB)  TX bytes:40099976 (38.2 MiB)

動作確認

初期状態のため何も登録されていない
# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE

コンテナの作成

CentOSのコンテナを作成してみる
# docker run -t -i centos /bin/bash
Unable to find image 'centos' locally
Pulling repository centos
0c752394b855: Download complete
511136ea3c5a: Download complete
34e94e67e63a: Download complete
# exit
Ubuntuのコンテナを作成してみる
# docker run -t -i ubuntu /bin/bash
Unable to find image 'ubuntu' locally
Pulling repository ubuntu
e54ca5efa2e9: Download complete
511136ea3c5a: Download complete
d7ac5e4f1812: Download complete
2f4b4d6a4a06: Download complete
83ff768040a0: Download complete
6c37f792ddac: Download complete

動作確認

# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
a112d4c9b807        ubuntu:latest       /bin/bash           3 minutes ago       Exited (0) 9 seconds ago                       naughty_galileo
1173ad2ccf4d        centos:latest       /bin/bash           20 minutes ago      Exited (0) 4 minutes ago                       loving_pike||=

コマンド

現在の情報(info)
# docker info
Containers: 1
Images: 3
Storage Driver: devicemapper
 Pool Name: docker-253:0-528028-pool
 Data file: /var/lib/docker/devicemapper/devicemapper/data
 Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata
 Data Space Used: 497.2 Mb
 Data Space Total: 102400.0 Mb
 Metadata Space Used: 0.9 Mb
 Metadata Space Total: 2048.0 Mb
Execution Driver: native-0.2
Kernel Version: 2.6.32-431.20.3.el6.x86_64
コンテナへのアタッチ(attach)
# docker attach 1173ad2ccf4d
bash-4.1#
コンテナの起動(start)
# docker start 1173ad2ccf4d
1173ad2ccf4d
コンテナの停止(stop)
# docker stop 1173ad2ccf4d
1173ad2ccf4d
コンテナの削除(rm)
docker rm 1173ad2ccf4d
1173ad2ccf4d

Menu

メニュー

アプリケーション

アプリケーション

その他

【メニュー編集】

管理人/副管理人のみ編集できます