2、安装Docker
1、我们可以打开Docker官网,上面有详细的步骤去简绍我们这么去安装Docker
#1、首先我们先要去卸载已安装的Docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
# 2、安装yum-utils安装包
sudo yum install -y yum-utils
# 3、设置镜像仓库
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo 不推荐使用这种,国外的,会特别慢
我们可以设置阿里的仓库
sudo yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 4、安装Docker
sudo yum install docker-ce docker-ce-cli containerd.io
# 5、启动docker
sudo systemctl start docker
# 6、使用docker version 查看docker是否启动成功
# 7、测试hello-world
[root@iZ2zee7khd9swlno7xr3hsZ ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally 未找到hello-world
latest: Pulling from library/hello-world 去docker仓库去拉取
b8dfde127a29: Pull complete
Digest: sha256:7d91b69e04a9029b99f3585aaaccae2baa80bcf318f4a5d2165a9898cd2dc0a1 签名
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/ 最终拉取的地址
# 8、查看docker镜像
docker images
# 9、卸载docker
sudo yum remove docker-ce docker-ce-cli containerd.io 移除安装的依赖
删除资源
sudo rm -rf /var/lib/docker docker的默认资源(工作)路径
sudo rm -rf /var/lib/containerd