CentOS 7にDocker CEをインストールしてみました。
https://www.docker.com/what-docker
Dockerプロダクトは2種類あり小規模、無償のDOCKER COMMUNITY EDITION (CE)と大規模、商用のDOCKER ENTERPRISE EDITION (EE)があります。
Select a Product
https://www.docker.com/get-docker
DOCKER COMMUNITY EDITION (CE)
Docker CE is available for free and is ideal for developers and small teams looking to get started with Docker to build container apps. Docker CE offers a monthly or quarterly release cadence for both the adventurous and practical developer.
DOCKER ENTERPRISE EDITION (EE)
Docker EE is a subscription of software, support and certification for enterprise dev and IT teams building and managing critical apps in production at scale. Docker EE provides a modern and trusted platform for all apps with integrated management and security across the app lifecycle.
Docker Pricing Plans
https://www.docker.com/pricing
Dockerの仕組みなどは多数の解説サイトがあるので、そちらを参考にしてして下さい。実は当方も今回が初めてなのです(^^;
それではCentOS 7にDocker CEをインストールしますが、下記のサイトを参考にしました。この通りに作業をするだけなんですが。
環境
・CentOS Linux release 7.3.1611 (Core)
・Kernel: 3.10.0-514.16.1.el7.x86_64
Install Docker
https://docs.docker.com/engine/installation/linux/centos/#install-docker
- repositoryの作成
- Docker CEインストール
- Dockerサービスの開始
- Dockerの動作確認
Docker CE repositoryを/etc/yum.repos.d/にダウンロードします。
[docker-ce-stable]だけ有効になっています。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# curl https://download.docker.com/linux/centos/docker-ce.repo > /etc/yum.repos.d/docker-ce.repo % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1802 100 1802 0 0 2790 0 --:--:-- --:--:-- --:--:-- 2789 # cat /etc/yum.repos.d/docker-ce.repo [docker-ce-stable] name=Docker CE Stable - $basearch baseurl=https://download.docker.com/linux/centos/7/$basearch/stable enabled=1 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-stable-debuginfo] name=Docker CE Stable - Debuginfo $basearch baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/stable enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-stable-source] name=Docker CE Stable - Sources baseurl=https://download.docker.com/linux/centos/7/source/stable enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-edge] name=Docker CE Edge - $basearch baseurl=https://download.docker.com/linux/centos/7/$basearch/edge enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-edge-debuginfo] name=Docker CE Edge - Debuginfo $basearch baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/edge enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-edge-source] name=Docker CE Edge - Sources baseurl=https://download.docker.com/linux/centos/7/source/edge enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-test] name=Docker CE Test - $basearch baseurl=https://download.docker.com/linux/centos/7/$basearch/test enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-test-debuginfo] name=Docker CE Test - Debuginfo $basearch baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/test enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg [docker-ce-test-source] name=Docker CE Test - Sources baseurl=https://download.docker.com/linux/centos/7/source/test enabled=0 gpgcheck=1 gpgkey=https://download.docker.com/linux/centos/gpg |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# yum info docker-ce Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.riken.jp * extras: ftp.riken.jp * updates: ftp.riken.jp Available Packages Name : docker-ce Arch : x86_64 Version : 17.03.1.ce Release : 1.el7.centos Size : 19 M Repo : docker-ce-stable/x86_64 Summary : The open-source application container engine URL : https://dockerproject.org License : ASL 2.0 Description : Docker is an open source project to build, ship and run any application as a : lightweight container. : : Docker containers are both hardware-agnostic and platform-agnostic. This means : they can run anywhere, from your laptop to the largest EC2 compute instance and : everything in between - and they don't require you to use a particular : language, framework or packaging system. That makes them great building blocks : for deploying and scaling web apps, databases, and backend services without : depending on a particular stack or provider. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# yum -y install docker-ce Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.riken.jp * extras: ftp.riken.jp * updates: ftp.riken.jp Resolving Dependencies --> Running transaction check ---> Package docker-ce.x86_64 0:17.03.1.ce-1.el7.centos will be installed --> Processing Dependency: docker-ce-selinux >= 17.03.1.ce-1.el7.centos for package: docker-ce-17.03.1.ce-1.el7.centos.x86_64 --> Processing Dependency: libcgroup for package: docker-ce-17.03.1.ce-1.el7.centos.x86_64 --> Processing Dependency: libltdl.so.7()(64bit) for package: docker-ce-17.03.1.ce-1.el7.centos.x86_64 --> Processing Dependency: libseccomp.so.2()(64bit) for package: docker-ce-17.03.1.ce-1.el7.centos.x86_64 --> Running transaction check ---> Package docker-ce-selinux.noarch 0:17.03.1.ce-1.el7.centos will be installed --> Processing Dependency: policycoreutils-python for package: docker-ce-selinux-17.03.1.ce-1.el7.centos.noarch ---> Package libcgroup.x86_64 0:0.41-11.el7 will be installed ---> Package libseccomp.x86_64 0:2.3.1-2.el7 will be installed ---> Package libtool-ltdl.x86_64 0:2.4.2-22.el7_3 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: 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_3.1 will be installed ---> Package checkpolicy.x86_64 0:2.5-4.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-ce x86_64 17.03.1.ce-1.el7.centos docker-ce-stable 19 M Installing for dependencies: audit-libs-python x86_64 2.6.5-3.el7_3.1 updates 70 k checkpolicy x86_64 2.5-4.el7 base 290 k docker-ce-selinux noarch 17.03.1.ce-1.el7.centos docker-ce-stable 28 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 libtool-ltdl x86_64 2.4.2-22.el7_3 updates 49 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 Transaction Summary ===================================================================================================================== Install 1 Package (+10 Dependent packages) Total download size: 20 M Installed size: 24 M Downloading packages: (1/11): audit-libs-python-2.6.5-3.el7_3.1.x86_64.rpm | 70 kB 00:00:00 (2/11): libcgroup-0.41-11.el7.x86_64.rpm | 65 kB 00:00:00 (3/11): libseccomp-2.3.1-2.el7.x86_64.rpm | 56 kB 00:00:00 (4/11): libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm | 49 kB 00:00:00 (5/11): checkpolicy-2.5-4.el7.x86_64.rpm | 290 kB 00:00:00 warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-selinux-17.03.1.ce-1.el7.centos.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY Public key for docker-ce-selinux-17.03.1.ce-1.el7.centos.noarch.rpm is not installed (6/11): docker-ce-selinux-17.03.1.ce-1.el7.centos.noarch.rpm | 28 kB 00:00:00 (7/11): libsemanage-python-2.5-5.1.el7_3.x86_64.rpm | 104 kB 00:00:00 (8/11): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00 (9/11): policycoreutils-python-2.5-11.el7_3.x86_64.rpm | 445 kB 00:00:00 (10/11): setools-libs-3.3.8-1.1.el7.x86_64.rpm | 612 kB 00:00:03 (11/11): docker-ce-17.03.1.ce-1.el7.centos.x86_64.rpm | 19 MB 00:00:19 --------------------------------------------------------------------------------------------------------------------- Total 1.1 MB/s | 20 MB 00:00:19 Retrieving key from https://download.docker.com/linux/centos/gpg Importing GPG key 0x621E9F35: Userid : "Docker Release (CE rpm) <docker@docker.com>" Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35 From : https://download.docker.com/linux/centos/gpg Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : libcgroup-0.41-11.el7.x86_64 1/11 Installing : setools-libs-3.3.8-1.1.el7.x86_64 2/11 Installing : checkpolicy-2.5-4.el7.x86_64 3/11 Installing : libtool-ltdl-2.4.2-22.el7_3.x86_64 4/11 Installing : libsemanage-python-2.5-5.1.el7_3.x86_64 5/11 Installing : audit-libs-python-2.6.5-3.el7_3.1.x86_64 6/11 Installing : python-IPy-0.75-6.el7.noarch 7/11 Installing : policycoreutils-python-2.5-11.el7_3.x86_64 8/11 Installing : docker-ce-selinux-17.03.1.ce-1.el7.centos.noarch 9/11 setsebool: SELinux is disabled. libsemanage.semanage_direct_install_info: Overriding docker module at lower priority 100 with module at priority 400. Installing : libseccomp-2.3.1-2.el7.x86_64 10/11 Installing : docker-ce-17.03.1.ce-1.el7.centos.x86_64 11/11 Verifying : libseccomp-2.3.1-2.el7.x86_64 1/11 Verifying : python-IPy-0.75-6.el7.noarch 2/11 Verifying : audit-libs-python-2.6.5-3.el7_3.1.x86_64 3/11 Verifying : libsemanage-python-2.5-5.1.el7_3.x86_64 4/11 Verifying : docker-ce-selinux-17.03.1.ce-1.el7.centos.noarch 5/11 Verifying : libtool-ltdl-2.4.2-22.el7_3.x86_64 6/11 Verifying : libcgroup-0.41-11.el7.x86_64 7/11 Verifying : policycoreutils-python-2.5-11.el7_3.x86_64 8/11 Verifying : docker-ce-17.03.1.ce-1.el7.centos.x86_64 9/11 Verifying : checkpolicy-2.5-4.el7.x86_64 10/11 Verifying : setools-libs-3.3.8-1.1.el7.x86_64 11/11 Installed: docker-ce.x86_64 0:17.03.1.ce-1.el7.centos Dependency Installed: audit-libs-python.x86_64 0:2.6.5-3.el7_3.1 checkpolicy.x86_64 0:2.5-4.el7 docker-ce-selinux.noarch 0:17.03.1.ce-1.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 libtool-ltdl.x86_64 0:2.4.2-22.el7_3 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 Complete! |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# systemctl list-unit-files | grep docker docker.service disabled # systemctl enable docker Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service. # systemctl start docker # systemctl status docker * docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2017-04-15 17:51:43 JST; 4s ago Docs: https://docs.docker.com Main PID: 1433 (dockerd) Memory: 15.4M CGroup: /system.slice/docker.service |-1433 /usr/bin/dockerd `-1438 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-inter... Apr 15 17:51:42 centos7.rootlinks.net dockerd[1433]: time="2017-04-15T17:51:42.956556151+09:00" level=warning msg=... Apr 15 17:51:42 centos7.rootlinks.net dockerd[1433]: time="2017-04-15T17:51:42.994939438+09:00" level=info msg...nds" Apr 15 17:51:42 centos7.rootlinks.net dockerd[1433]: time="2017-04-15T17:51:42.995626395+09:00" level=info msg...rt." Apr 15 17:51:43 centos7.rootlinks.net dockerd[1433]: time="2017-04-15T17:51:43.009155793+09:00" level=info msg...rue" Apr 15 17:51:43 centos7.rootlinks.net dockerd[1433]: time="2017-04-15T17:51:43.176223537+09:00" level=info msg...ess" Apr 15 17:51:43 centos7.rootlinks.net dockerd[1433]: time="2017-04-15T17:51:43.321845389+09:00" level=info msg...ne." Apr 15 17:51:43 centos7.rootlinks.net dockerd[1433]: time="2017-04-15T17:51:43.329207303+09:00" level=info msg...ion" Apr 15 17:51:43 centos7.rootlinks.net dockerd[1433]: time="2017-04-15T17:51:43.329251076+09:00" level=info msg...1-ce Apr 15 17:51:43 centos7.rootlinks.net dockerd[1433]: time="2017-04-15T17:51:43.340720979+09:00" level=info msg...ock" Apr 15 17:51:43 centos7.rootlinks.net systemd[1]: Started Docker Application Container Engine. Hint: Some lines were ellipsized, use -l to show in full. |
このコマンドでテストイメージをダウンロード、コンテナ内で実行します。コンテナが実行されると、”Hello from Docker!”が出力され終了します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 78445dd45222: Pull complete Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://cloud.docker.com/ For more examples and ideas, visit: https://docs.docker.com/engine/userguide/ |