CentOS7.4にDockerをインストールする
1.既存Dockerを削除
# sudo yum remove docker docker-common docker-selinux docker-engine
2.必要なパッケージをインストール
# sudo yum install -y yum-utils device-mapper-persistent-data lvm2
中略
Dependency Installed:
device-mapper-event.x86_64 7:1.02.140-8.el7
device-mapper-event-libs.x86_64 7:1.02.140-8.el7
libxml2-python.x86_64 0:2.9.1-6.el7_2.3
lvm2-libs.x86_64 7:2.02.171-8.el7
python-chardet.noarch 0:2.2.1-1.el7_1
python-kitchen.noarch 0:1.1.1-5.el7
Complete!
3.レポジトリを追加
# sudo yum-config-manager –add-repo https://download.dock
er.com/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
4.パッケージインデックスを更新
# sudo yum makecache fast
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00
centosplus | 2.9 kB 00:00
docker-ce-stable | 2.9 kB 00:00
epel/x86_64/metalink | 6.8 kB 00:00
extras | 3.4 kB 00:00
nginx | 2.9 kB 00:00
remi-safe | 2.9 kB 00:00
updates | 3.4 kB 00:00
docker-ce-stable/x86_64/primary_db | 9.3 kB 00:00
Loading mirror speeds from cached hostfile
* epel: mirror.dmmlabs.jp
* remi-safe: mirrors.tuna.tsinghua.edu.cn
Metadata Cache Created
5.Dockerインストール
# sudo yum install docker-ce-17.06.0.ce-1.el7.centos
中略
Installed:
docker-ce.x86_64 0:17.06.0.ce-1.el7.centos
Dependency Installed:
container-selinux.noarch 2:2.21-2.gitba103ac.el7
iptables.x86_64 0:1.4.21-18.0.1.el7.centos
libmnl.x86_64 0:1.0.3-7.el7
libnetfilter_conntrack.x86_64 0:1.0.6-1.el7_3
libnfnetlink.x86_64 0:1.0.1-4.el7
libseccomp.x86_64 0:2.3.1-3.el7
selinux-policy.noarch 0:3.13.1-166.el7_4.4
selinux-policy-targeted.noarch 0:3.13.1-166.el7_4.4
6.起動
#sudo systemctl start docker
確認
#sudo docker run hello-world
Unable to find image 'hello-world:latest’ locally
latest: Pulling from library/hello-world
5b0f327be733: Pull complete
Digest: sha256:07d5f7800dfe37b8c2196c7b1c524c33808ce2e0f74e7aa00e603295ca9a0972
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/
Dockerを自動起動
#sudo systemctl enable docker