1)Docker安装所需要CentOS7以上才可以安装
2)安装所需的软件包
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
3)设置 stable 镜像仓库:
$ sudo yum-config-manager
–add-repo
https://download.docker.com/linux/centos/docker-ce.repo
4)启用 edge 和 testing 镜像仓库:
$ sudo yum-config-manager --enable docker-ce-edge
$ sudo yum-config-manager --enable docker-ce-testing
5)更新yum软件包索引:
$ sudo yum makecache fast
6)安装Docker最新版本:
$ sudo yum install docker-ce
7)启动Docker:
$ sudo systemctl start docker
8)验证是否启动成功:
$ sudo docker run hello-world
然后出现了以下信息:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
解决办法:
$ systemctl daemon-reload
$ sudo service docker restart
$ sudo service docker status (should see active (running))
9)再次运行$ sudo docker run hello-world
[root@localhost ~]# sudo docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
- The Docker client contacted the Docker daemon.
- The Docker daemon pulled the “hello-world” image from the Docker Hub.
(amd64) - The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading. - 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正常运行了。