目前Docker支持centos 7及以后版本。
本文中使用的是centos7系统。
$ sudo yum install update
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
官方源
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
有时由于网络问题,无法访问官方源,也可以添加国内源:
$ sudo yum-config-manager --add-repo https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
$ sudo yum install docker-ce
安装过程中,也会将docker-ce-cli, containerd.io 作为依赖进行安装。
sudo systemctl start docker
查看docker进程是否已经启动:
$ ps -ef| grep docker
root 12486 1 0 23:21 ? 00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
lanyang 12639 10783 0 23:21 pts/0 00:00:00 grep --color=auto docker
查看docker版本信息:
[lanyang@localhost ~]$ sudo docker version
Client: Docker Engine - Community
Version: 19.03.5
API version: 1.40
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:25:41 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.5
API version: 1.40 (minimum version 1.12)
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:24:18 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.10
GitCommit: b34a5c8af56e510852c35414db4c1f4fa6172339
runc:
Version: 1.0.0-rc8+dev
GitCommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
docker-init:
Version: 0.18.0
GitCommit: fec3683
通过运行 hello-world 映像来验证是否正确安装了 Docker Engine-Community
[lanyang@localhost ~]$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Already exists
Digest: sha256:9572f7cdcee8591948c2963463447a53466950b3fc15a247fcad1917ca215a2f
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.
(amd64)
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://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
上面的输出,表示docker已经安装成功。
执行hello-world的过程如下:.
原文:https://www.cnblogs.com/lanyangsh/p/12244956.html