GMOクラウド ALTUSを使ってみるぞい!第二回Docker編

今回はdockerインストールとCentOSのコンテナの作成を行います

こちらのページを参考にして進めました

VMの環境は以下の通り


CentOS Linux release 7.3.1611 (Core)

メモリ:512MB

ディスク容量:20GB(ルートディスク)


手順の通りコマンドを実行してみる

と初っ端から躓いたw

・エラー

network is unreachableとかなんとかと出てyum updateができなかった

・原因

firewallの送信側の設定にポート80の許可設定が書いてなかったため

yumは80番ポートを使っているよう

・やったこと

firewallの内部から外部へのアクセスでポート80を許可する設定をする

なんとかyum updateもできていざDockerのインストール!

Dockerのインストール手順

1.Extra Packages for Enterprise Linux (EPEL)リポジトリを追加

2.Dockerのパッケージを取得しインストール

3.Dockerデーモンを起動

4.OSを再起動した時に自動的にDockerデーモンが起動するように設定

5.最後にHello world的なことを
イメージからコンテナを作成してコンテナ内のシェルに入る


実行コマンドと結果

実行コマンド


1.yum install epel-release

2.yum install docker-io

3.service docker start

4.chkconfig docker on

5.docker run -it centos /bin/bash


結果


1.

#yum install epel-release

Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
updates/7/x86_64/primary_db | 2.2 MB 00:00:00
Loading mirror speeds from cached hostfile
* base: ftp.riken.jp
* extras: ftp.riken.jp
* updates: ftp.riken.jp
Resolving Dependencies
–> Running transaction check
—> Package epel-release.noarch 0:7-9 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================
Package Arch Version Repository Size
=======================================================================================================
Installing:
epel-release noarch 7-9 extras 14 k

Transaction Summary
=======================================================================================================
Install 1 Package

Total download size: 14 k
Installed size: 24 k
Is this ok [y/d/N]: y
Downloading packages:
epel-release-7-9.noarch.rpm | 14 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-9.noarch 1/1
Verifying : epel-release-7-9.noarch 1/1

Installed:
epel-release.noarch 0:7-9

Complete!

2.

実行してみたものの以下のエラーが出る

Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again

こちらのページを参考にして修正してみる

#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch

↓

baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch

# vi /etc/yum.repos.d/epel.repo

と修正してもう一度手順1のやつを実行

# yum install epel-release
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
base | 3.6 kB 00:00:00
centosplus | 3.4 kB 00:00:00
epel | 4.3 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/8): base/7/x86_64/group_gz | 155 kB 00:00:00
(2/8): centosplus/7/x86_64/primary_db | 1.1 MB 00:00:00
(3/8): base/7/x86_64/primary_db | 5.6 MB 00:00:00
(4/8): epel/x86_64/updateinfo | 735 kB 00:00:00
(5/8): extras/7/x86_64/primary_db | 121 kB 00:00:00
(6/8): epel/x86_64/group_gz | 170 kB 00:00:00
(7/8): updates/7/x86_64/primary_db | 2.2 MB 00:00:00
(8/8): epel/x86_64/primary_db | 4.5 MB 00:00:01
Determining fastest mirrors
* base: ftp.riken.jp
* centosplus: mirror.qoxy.com
* extras: mirror.qoxy.com
* updates: ftp.riken.jp
Package epel-release-7-9.noarch already installed and latest version
Nothing to do

気を取り直してもう一度トライ

# yum install docker-io
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* base: ftp.riken.jp
* centosplus: mirror.qoxy.com
* extras: mirror.qoxy.com
* updates: ftp.riken.jp
Resolving Dependencies
–> Running transaction check
—> Package docker.x86_64 2:1.12.5-14.el7.centos will be installed
–> Processing Dependency: docker-common = 2:1.12.5-14.el7.centos for package: 2:docker-1.12.5-14.el7.centos.x86_64
–> Processing Dependency: docker-client = 2:1.12.5-14.el7.centos for package: 2:docker-1.12.5-14.el7.centos.x86_64
–> Processing Dependency: oci-systemd-hook >= 1:0.1.4-8 for package: 2:docker-1.12.5-14.el7.centos.x86_64
–> Processing Dependency: oci-register-machine >= 1:0-1.11 for package: 2:docker-1.12.5-14.el7.centos.x86_64
–> Processing Dependency: container-selinux >= 2:1.12.5-14.el7.centos for package: 2:docker-1.12.5-14.el7.centos.x86_64
–> Processing Dependency: skopeo-containers for package: 2:docker-1.12.5-14.el7.centos.x86_64
–> Processing Dependency: libseccomp.so.2()(64bit) for package: 2:docker-1.12.5-14.el7.centos.x86_64
–> Running transaction check
—> Package container-selinux.x86_64 2:1.12.5-14.el7.centos will be installed
–> Processing Dependency: policycoreutils-python for package: 2:container-selinux-1.12.5-14.el7.centos.x86_64
—> Package docker-client.x86_64 2:1.12.5-14.el7.centos will be installed
—> Package docker-common.x86_64 2:1.12.5-14.el7.centos will be installed
—> Package libseccomp.x86_64 0:2.3.1-2.el7 will be installed
—> Package oci-register-machine.x86_64 1:0-1.11.gitdd0daef.el7 will be installed
—> Package oci-systemd-hook.x86_64 1:0.1.4-9.git671c428.el7 will be installed
—> Package skopeo-containers.x86_64 1:0.1.17-1.el7 will be installed
–> Running transaction check
—> Package policycoreutils-python.x86_64 0:2.5-11.el7_3 will be installed
–> Processing Dependency: setools-libs >= 3.3.8-1 for package: policycoreutils-python-2.5-11.el7_3.x86_64
–> Processing Dependency: libsemanage-python >= 2.5-5 for package: policycoreutils-python-2.5-11.el7_3.x86_64
–> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-11.el7_3.x86_64
–> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-11.el7_3.x86_64
–> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64
–> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64
–> Processing Dependency: libcgroup for package: policycoreutils-python-2.5-11.el7_3.x86_64
–> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64
–> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-11.el7_3.x86_64
–> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64
–> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64
–> Running transaction check
—> Package audit-libs-python.x86_64 0:2.6.5-3.el7 will be installed
—> Package checkpolicy.x86_64 0:2.5-4.el7 will be installed
—> Package libcgroup.x86_64 0:0.41-11.el7 will be installed
—> Package libsemanage-python.x86_64 0:2.5-5.1.el7_3 will be installed
—> Package python-IPy.noarch 0:0.75-6.el7 will be installed
—> Package setools-libs.x86_64 0:3.3.8-1.1.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================
Package Arch Version Repository Size
=======================================================================================================
Installing:
docker x86_64 2:1.12.5-14.el7.centos extras 20 M
Installing for dependencies:
audit-libs-python x86_64 2.6.5-3.el7 base 70 k
checkpolicy x86_64 2.5-4.el7 base 290 k
container-selinux x86_64 2:1.12.5-14.el7.centos extras 86 k
docker-client x86_64 2:1.12.5-14.el7.centos extras 4.4 M
docker-common x86_64 2:1.12.5-14.el7.centos extras 69 k
libcgroup x86_64 0.41-11.el7 base 65 k
libseccomp x86_64 2.3.1-2.el7 base 56 k
libsemanage-python x86_64 2.5-5.1.el7_3 updates 104 k
oci-register-machine x86_64 1:0-1.11.gitdd0daef.el7 extras 1.1 M
oci-systemd-hook x86_64 1:0.1.4-9.git671c428.el7 extras 29 k
policycoreutils-python x86_64 2.5-11.el7_3 updates 445 k
python-IPy noarch 0.75-6.el7 base 32 k
setools-libs x86_64 3.3.8-1.1.el7 base 612 k
skopeo-containers x86_64 1:0.1.17-1.el7 extras 7.4 k

Transaction Summary
=======================================================================================================
Install 1 Package (+14 Dependent packages)

Total download size: 27 M
Installed size: 109 M
Is this ok [y/d/N]: y
Downloading packages:
(1/15): audit-libs-python-2.6.5-3.el7.x86_64.rpm | 70 kB 00:00:00
(2/15): checkpolicy-2.5-4.el7.x86_64.rpm | 290 kB 00:00:00
(3/15): container-selinux-1.12.5-14.el7.centos.x86_64.rpm | 86 kB 00:00:00
(4/15): docker-client-1.12.5-14.el7.centos.x86_64.rpm | 4.4 MB 00:00:00
(5/15): docker-common-1.12.5-14.el7.centos.x86_64.rpm | 69 kB 00:00:00
(6/15): libcgroup-0.41-11.el7.x86_64.rpm | 65 kB 00:00:00
(7/15): libseccomp-2.3.1-2.el7.x86_64.rpm | 56 kB 00:00:00
(8/15): libsemanage-python-2.5-5.1.el7_3.x86_64.rpm | 104 kB 00:00:00
(9/15): oci-register-machine-0-1.11.gitdd0daef.el7.x86_64.rpm | 1.1 MB 00:00:00
(10/15): oci-systemd-hook-0.1.4-9.git671c428.el7.x86_64.rpm | 29 kB 00:00:00
(11/15): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00
(12/15): policycoreutils-python-2.5-11.el7_3.x86_64.rpm | 445 kB 00:00:00
(13/15): setools-libs-3.3.8-1.1.el7.x86_64.rpm | 612 kB 00:00:00
(14/15): skopeo-containers-0.1.17-1.el7.x86_64.rpm | 7.4 kB 00:00:00
(15/15): docker-1.12.5-14.el7.centos.x86_64.rpm | 20 MB 00:00:02
——————————————————————————————————-
Total 11 MB/s | 27 MB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 2:docker-common-1.12.5-14.el7.centos.x86_64 1/15
Installing : 2:docker-client-1.12.5-14.el7.centos.x86_64 2/15
Installing : setools-libs-3.3.8-1.1.el7.x86_64 3/15
Installing : 1:oci-systemd-hook-0.1.4-9.git671c428.el7.x86_64 4/15
Installing : 1:oci-register-machine-0-1.11.gitdd0daef.el7.x86_64 5/15
Installing : python-IPy-0.75-6.el7.noarch 6/15
Installing : 1:skopeo-containers-0.1.17-1.el7.x86_64 7/15
Installing : libsemanage-python-2.5-5.1.el7_3.x86_64 8/15
Installing : audit-libs-python-2.6.5-3.el7.x86_64 9/15
Installing : checkpolicy-2.5-4.el7.x86_64 10/15
Installing : libcgroup-0.41-11.el7.x86_64 11/15
Installing : policycoreutils-python-2.5-11.el7_3.x86_64 12/15
Installing : 2:container-selinux-1.12.5-14.el7.centos.x86_64 13/15
Installing : libseccomp-2.3.1-2.el7.x86_64 14/15
Installing : 2:docker-1.12.5-14.el7.centos.x86_64 15/15
Verifying : libseccomp-2.3.1-2.el7.x86_64 1/15
Verifying : libcgroup-0.41-11.el7.x86_64 2/15
Verifying : checkpolicy-2.5-4.el7.x86_64 3/15
Verifying : 2:docker-1.12.5-14.el7.centos.x86_64 4/15
Verifying : audit-libs-python-2.6.5-3.el7.x86_64 5/15
Verifying : libsemanage-python-2.5-5.1.el7_3.x86_64 6/15
Verifying : 1:skopeo-containers-0.1.17-1.el7.x86_64 7/15
Verifying : python-IPy-0.75-6.el7.noarch 8/15
Verifying : 2:docker-common-1.12.5-14.el7.centos.x86_64 9/15
Verifying : 2:docker-client-1.12.5-14.el7.centos.x86_64 10/15
Verifying : 1:oci-register-machine-0-1.11.gitdd0daef.el7.x86_64 11/15
Verifying : policycoreutils-python-2.5-11.el7_3.x86_64 12/15
Verifying : 2:container-selinux-1.12.5-14.el7.centos.x86_64 13/15
Verifying : 1:oci-systemd-hook-0.1.4-9.git671c428.el7.x86_64 14/15
Verifying : setools-libs-3.3.8-1.1.el7.x86_64 15/15

Installed:
docker.x86_64 2:1.12.5-14.el7.centos

Dependency Installed:
audit-libs-python.x86_64 0:2.6.5-3.el7 checkpolicy.x86_64 0:2.5-4.el7
container-selinux.x86_64 2:1.12.5-14.el7.centos docker-client.x86_64 2:1.12.5-14.el7.centos
docker-common.x86_64 2:1.12.5-14.el7.centos libcgroup.x86_64 0:0.41-11.el7
libseccomp.x86_64 0:2.3.1-2.el7 libsemanage-python.x86_64 0:2.5-5.1.el7_3
oci-register-machine.x86_64 1:0-1.11.gitdd0daef.el7 oci-systemd-hook.x86_64 1:0.1.4-9.git671c428.el7
policycoreutils-python.x86_64 0:2.5-11.el7_3 python-IPy.noarch 0:0.75-6.el7
setools-libs.x86_64 0:3.3.8-1.1.el7 skopeo-containers.x86_64 1:0.1.17-1.el7

Complete!

よし、うまくいったようだ

3.

# service docker start
Redirecting to /bin/systemctl start docker.service

4.
# chkconfig docker on
Note: Forwarding request to ‘systemctl enable docker.service’.
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

5.
# docker run -it centos /bin/bash
[root@0797ba0aaaeb /]#

プロンプトが変わり、サーバー名のところはCentOSのイメージIDになっていてコンテナに入っていることが確認できる

出るときはexitを打つともとに戻る


これでdockerインストールとコンテナの作成は完了

シェアする

  • このエントリーをはてなブックマークに追加

フォローする