社内の開発環境等、非インターネット接続環境でのDocker Engineのセットアップ方法の作業メモ
前提環境
- 検証用のため、AWS上に環境を準備。
利用AMI:RHEL-7.1_HVM-20150803-x86_64-1-Hourly2-GP2
インスタンスタイプ:t2.medium(2vCPU/4GiB)
RHEL7.1環境
Red Hat Enterprise Linux Server release 7.1 (Maipo)
Docker導入準備
インターネット接続環境であれば、以下手順に従い、yum installで一発だが、今回は非インターネット接続環境という前提の為、依存性を解決しつつ、必要なrpmを準備
http://docs.docker.jp/engine/installation/linux/rhel.html
- Red Hat Customer PortalよりDocker Engineのパッケージ一式をダウンロード
必要RPM一覧
[root@ip-172-31-47-162 docker]# ls -ltr
total 13100
-rw-r--r--. 1 ec2-user ec2-user 56232 Sep 22 06:16 docker-selinux-1.6.2-14.el7.x86_64.rpm
-rw-r--r--. 1 ec2-user ec2-user 7969356 Sep 22 06:19 docker-1.6.2-14.el7.x86_64.rpm
-rw-r--r--. 1 ec2-user ec2-user 918432 Sep 22 06:20 lvm2-2.02.115-3.el7_1.2.x86_64.rpm
-rw-r--r--. 1 ec2-user ec2-user 783492 Sep 22 06:22 lvm2-libs-2.02.115-3.el7_1.2.x86_64.rpm
-rw-r--r--. 1 ec2-user ec2-user 214388 Sep 22 06:28 device-mapper-1.02.93-3.el7_1.2.x86_64.rpm
-rw-r--r--. 1 ec2-user ec2-user 162532 Sep 22 06:28 device-mapper-event-1.02.93-3.el7_1.2.x86_64.rpm
-rw-r--r--. 1 ec2-user ec2-user 155168 Sep 22 06:28 device-mapper-event-libs-1.02.93-3.el7_1.2.x86_64.rpm
-rw-r--r--. 1 ec2-user ec2-user 265880 Sep 22 06:28 device-mapper-libs-1.02.93-3.el7_1.2.x86_64.rpm
-rw-r--r--. 1 ec2-user ec2-user 2869284 Sep 22 06:28 device-mapper-persistent-data-0.3.2-1.el7.x86_64.rpm
[root@ip-172-31-47-162 docker]#
- まずは、Docker Engineのメインのパッケージである、「docker-1.6.2-14」をダウンロードの上、yum localinstallにて、依存性のあるパッケージを抽出。
- 新しいDocker Engineバージョンだと、依存性地獄で面倒なので、あえて古いバージョン(RHEL7.1と親和性高そうなもの)を選択。。。
- Red Hat Customer Portalより必要なパッケージをダウンロードし、SCPにてAWS上のRHEL環境に転送。
- 非インターネット接続環境とする為、EC2のセキュリティグループのアウトバウンドは、全て拒否設定。(これにより、EC2からインターネット接続は不可。)
- デフォルトのrepo設定だと、以下エラーが出力され、localinstallすらできない(アウトバウンド拒否している為、デフォルトのrepoに問い合わせできない)為、設定変更。
エラー出力
[root@ip-172-31-47-162 docker]# yum localinstall ./*
Loaded plugins: amazon-id, rhui-lb
Examining ./container-selinux-2.10-2.el7.noarch.rpm: 2:container-selinux-2.10-2.el7.noarch
Marking ./container-selinux-2.10-2.el7.noarch.rpm to be installed
Examining ./docker-1.12.6-16.el7.x86_64.rpm: 2:docker-1.12.6-16.el7.x86_64
Marking ./docker-1.12.6-16.el7.x86_64.rpm to be installed
Examining ./docker-client-1.12.6-16.el7.x86_64.rpm: 2:docker-client-1.12.6-16.el7.x86_64
Marking ./docker-client-1.12.6-16.el7.x86_64.rpm to be installed
Examining ./docker-common-1.12.6-16.el7.x86_64.rpm: 2:docker-common-1.12.6-16.el7.x86_64
Marking ./docker-common-1.12.6-16.el7.x86_64.rpm to be installed
Examining ./docker-rhel-push-plugin-1.12.6-16.el7.x86_64.rpm: 2:docker-rhel-push-plugin-1.12.6-16.el7.x86_64
Marking ./docker-rhel-push-plugin-1.12.6-16.el7.x86_64.rpm to be installed
Examining ./oci-register-machine-0-3.11.gitdd0daef.el7.x86_64.rpm: 1:oci-register-machine-0-3.11.gitdd0daef.el7.x86_64
Marking ./oci-register-machine-0-3.11.gitdd0daef.el7.x86_64.rpm to be installed
Examining ./oci-systemd-hook-0.1.4-9.git671c428.el7.x86_64.rpm: 1:oci-systemd-hook-0.1.4-9.git671c428.el7.x86_64
Marking ./oci-systemd-hook-0.1.4-9.git671c428.el7.x86_64.rpm to be installed
Examining ./skopeo-containers-0.1.20-2.el7.x86_64.rpm: 1:skopeo-containers-0.1.20-2.el7.x86_64
Marking ./skopeo-containers-0.1.20-2.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package container-selinux.noarch 2:2.10-2.el7 will be installed
--> Processing Dependency: policycoreutils >= 2.5-11 for package: 2:container-selinux-2.10-2.el7.noarch
Could not contact CDS load balancer rhui2-cds01.ap-northeast-1.aws.ce.redhat.com, trying others.
Could not contact any CDS load balancers: rhui2-cds01.ap-northeast-1.aws.ce.redhat.com, rhui2-cds02.ap-northeast-1.aws.ce.redhat.com.
[root@ip-172-31-47-162 docker]#
repoの設定変更
[root@ip-172-31-47-162 yum.repos.d]# yum-config-manager --save --setopt=local-myrepository.skip_if_unavailable=true
Docker Engineのインストール
- yum localinstallコマンドにてDocker Engineのインストール
インストールの実行
[root@ip-172-31-47-162 docker]# yum localinstall ./*
Loaded plugins: amazon-id, rhui-lb
Examining ./device-mapper-1.02.93-3.el7_1.2.x86_64.rpm: 7:device-mapper-1.02.93-3.el7_1.2.x86_64
Marking ./device-mapper-1.02.93-3.el7_1.2.x86_64.rpm as an update to 7:device-mapper-1.02.93-3.el7_1.1.x86_64
Examining ./device-mapper-event-1.02.93-3.el7_1.2.x86_64.rpm: 7:device-mapper-event-1.02.93-3.el7_1.2.x86_64
Marking ./device-mapper-event-1.02.93-3.el7_1.2.x86_64.rpm to be installed
Examining ./device-mapper-event-libs-1.02.93-3.el7_1.2.x86_64.rpm: 7:device-mapper-event-libs-1.02.93-3.el7_1.2.x86_64
Marking ./device-mapper-event-libs-1.02.93-3.el7_1.2.x86_64.rpm to be installed
Examining ./device-mapper-libs-1.02.93-3.el7_1.2.x86_64.rpm: 7:device-mapper-libs-1.02.93-3.el7_1.2.x86_64
Marking ./device-mapper-libs-1.02.93-3.el7_1.2.x86_64.rpm as an update to 7:device-mapper-libs-1.02.93-3.el7_1.1.x86_64
Examining ./device-mapper-persistent-data-0.3.2-1.el7.x86_64.rpm: device-mapper-persistent-data-0.3.2-1.el7.x86_64
Marking ./device-mapper-persistent-data-0.3.2-1.el7.x86_64.rpm to be installed
Examining ./docker-1.6.2-14.el7.x86_64.rpm: docker-1.6.2-14.el7.x86_64
Marking ./docker-1.6.2-14.el7.x86_64.rpm to be installed
Examining ./docker-selinux-1.6.2-14.el7.x86_64.rpm: docker-selinux-1.6.2-14.el7.x86_64
Marking ./docker-selinux-1.6.2-14.el7.x86_64.rpm to be installed
Examining ./lvm2-2.02.115-3.el7_1.2.x86_64.rpm: 7:lvm2-2.02.115-3.el7_1.2.x86_64
Marking ./lvm2-2.02.115-3.el7_1.2.x86_64.rpm to be installed
Examining ./lvm2-libs-2.02.115-3.el7_1.2.x86_64.rpm: 7:lvm2-libs-2.02.115-3.el7_1.2.x86_64
Marking ./lvm2-libs-2.02.115-3.el7_1.2.x86_64.rpm to be installed
Skipping: ./old, filename does not end in .rpm.
Resolving Dependencies
--> Running transaction check
---> Package device-mapper.x86_64 7:1.02.93-3.el7_1.1 will be updated
---> Package device-mapper.x86_64 7:1.02.93-3.el7_1.2 will be an update
---> Package device-mapper-event.x86_64 7:1.02.93-3.el7_1.2 will be installed
---> Package device-mapper-event-libs.x86_64 7:1.02.93-3.el7_1.2 will be installed
---> Package device-mapper-libs.x86_64 7:1.02.93-3.el7_1.1 will be updated
---> Package device-mapper-libs.x86_64 7:1.02.93-3.el7_1.2 will be an update
---> Package device-mapper-persistent-data.x86_64 0:0.3.2-1.el7 will be installed
---> Package docker.x86_64 0:1.6.2-14.el7 will be installed
---> Package docker-selinux.x86_64 0:1.6.2-14.el7 will be installed
---> Package lvm2.x86_64 7:2.02.115-3.el7_1.2 will be installed
---> Package lvm2-libs.x86_64 7:2.02.115-3.el7_1.2 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================
Package Arch Version Repository Size
========================================================================================================================
Installing:
device-mapper-event x86_64 7:1.02.93-3.el7_1.2 /device-mapper-event-1.02.93-3.el7_1.2.x86_64 37 k
device-mapper-event-libs x86_64 7:1.02.93-3.el7_1.2 /device-mapper-event-libs-1.02.93-3.el7_1.2.x86_64 27 k
device-mapper-persistent-data x86_64 0.3.2-1.el7 /device-mapper-persistent-data-0.3.2-1.el7.x86_64 17 M
docker x86_64 1.6.2-14.el7 /docker-1.6.2-14.el7.x86_64 32 M
docker-selinux x86_64 1.6.2-14.el7 /docker-selinux-1.6.2-14.el7.x86_64 25 k
lvm2 x86_64 7:2.02.115-3.el7_1.2 /lvm2-2.02.115-3.el7_1.2.x86_64 1.8 M
lvm2-libs x86_64 7:2.02.115-3.el7_1.2 /lvm2-libs-2.02.115-3.el7_1.2.x86_64 2.2 M
Updating:
device-mapper x86_64 7:1.02.93-3.el7_1.2 /device-mapper-1.02.93-3.el7_1.2.x86_64 189 k
device-mapper-libs x86_64 7:1.02.93-3.el7_1.2 /device-mapper-libs-1.02.93-3.el7_1.2.x86_64 293 k
Transaction Summary
========================================================================================================================
Install 7 Packages
Upgrade 2 Packages
Total size: 54 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : 7:device-mapper-1.02.93-3.el7_1.2.x86_64 1/11
Updating : 7:device-mapper-libs-1.02.93-3.el7_1.2.x86_64 2/11
Installing : 7:device-mapper-event-libs-1.02.93-3.el7_1.2.x86_64 3/11
Installing : 7:device-mapper-event-1.02.93-3.el7_1.2.x86_64 4/11
Installing : 7:lvm2-libs-2.02.115-3.el7_1.2.x86_64 5/11
Installing : docker-selinux-1.6.2-14.el7.x86_64 6/11
Installing : device-mapper-persistent-data-0.3.2-1.el7.x86_64 7/11
Installing : 7:lvm2-2.02.115-3.el7_1.2.x86_64 8/11
Installing : docker-1.6.2-14.el7.x86_64 9/11
Cleanup : 7:device-mapper-1.02.93-3.el7_1.1.x86_64 10/11
Cleanup : 7:device-mapper-libs-1.02.93-3.el7_1.1.x86_64 11/11
Verifying : device-mapper-persistent-data-0.3.2-1.el7.x86_64 1/11
Verifying : 7:lvm2-2.02.115-3.el7_1.2.x86_64 2/11
Verifying : 7:device-mapper-libs-1.02.93-3.el7_1.2.x86_64 3/11
Verifying : 7:device-mapper-event-libs-1.02.93-3.el7_1.2.x86_64 4/11
Verifying : docker-1.6.2-14.el7.x86_64 5/11
Verifying : 7:device-mapper-event-1.02.93-3.el7_1.2.x86_64 6/11
Verifying : 7:lvm2-libs-2.02.115-3.el7_1.2.x86_64 7/11
Verifying : 7:device-mapper-1.02.93-3.el7_1.2.x86_64 8/11
Verifying : docker-selinux-1.6.2-14.el7.x86_64 9/11
Verifying : 7:device-mapper-1.02.93-3.el7_1.1.x86_64 10/11
Verifying : 7:device-mapper-libs-1.02.93-3.el7_1.1.x86_64 11/11
Installed:
device-mapper-event.x86_64 7:1.02.93-3.el7_1.2 device-mapper-event-libs.x86_64 7:1.02.93-3.el7_1.2
device-mapper-persistent-data.x86_64 0:0.3.2-1.el7 docker.x86_64 0:1.6.2-14.el7
docker-selinux.x86_64 0:1.6.2-14.el7 lvm2.x86_64 7:2.02.115-3.el7_1.2
lvm2-libs.x86_64 7:2.02.115-3.el7_1.2
Updated:
device-mapper.x86_64 7:1.02.93-3.el7_1.2 device-mapper-libs.x86_64 7:1.02.93-3.el7_1.2
Complete!
[root@ip-172-31-47-162 docker]#
インストール後の稼働確認
- docker engineの起動&ステータス確認
DockerEngineの起動&起動確認
[root@ip-172-31-47-162 docker]# systemctl start docker
[root@ip-172-31-47-162 docker]#
[root@ip-172-31-47-162 docker]# systemctl status docker
docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled)
Active: active (running) since Tue 2020-09-22 06:29:23 EDT; 10s ago
Docs: http://docs.docker.com
Main PID: 18149 (docker)
CGroup: /system.slice/docker.service
└─18149 /usr/bin/docker -d --selinux-enabled --add-registry registry.access.redhat.com
Sep 22 06:29:16 ip-172-31-47-162.ap-northeast-1.compute.internal docker[18149]: time="2020-09-22T06:29:16-04:00" lev..."
Sep 22 06:29:22 ip-172-31-47-162.ap-northeast-1.compute.internal docker[18149]: time="2020-09-22T06:29:22-04:00" lev..."
Sep 22 06:29:23 ip-172-31-47-162.ap-northeast-1.compute.internal docker[18149]: time="2020-09-22T06:29:23-04:00" lev..."
Sep 22 06:29:23 ip-172-31-47-162.ap-northeast-1.compute.internal docker[18149]: time="2020-09-22T06:29:23-04:00" lev..."
Sep 22 06:29:23 ip-172-31-47-162.ap-northeast-1.compute.internal docker[18149]: time="2020-09-22T06:29:23-04:00" lev..."
Sep 22 06:29:23 ip-172-31-47-162.ap-northeast-1.compute.internal docker[18149]: time="2020-09-22T06:29:23-04:00" lev..."
Sep 22 06:29:23 ip-172-31-47-162.ap-northeast-1.compute.internal docker[18149]: time="2020-09-22T06:29:23-04:00" lev..."
Sep 22 06:29:23 ip-172-31-47-162.ap-northeast-1.compute.internal docker[18149]: time="2020-09-22T06:29:23-04:00" lev..."
Sep 22 06:29:23 ip-172-31-47-162.ap-northeast-1.compute.internal docker[18149]: time="2020-09-22T06:29:23-04:00" lev..."
Sep 22 06:29:23 ip-172-31-47-162.ap-northeast-1.compute.internal systemd[1]: Started Docker Application Container E...e.
Hint: Some lines were ellipsized, use -l to show in full.
[root@ip-172-31-47-162 docker]#
[root@ip-172-31-47-162 docker]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@ip-172-31-47-162 docker]#
- 外部接続できない為、docker searchコマンドは失敗(想定通り)
エラー出力
[root@ip-172-31-47-162 docker]# docker search hello-world
FATA[0127] Error response from daemon: Get https://index.docker.io/v1/search?q=hello-world: dial tcp 52.55.43.248:443: connection timed out
[root@ip-172-31-47-162 docker]#