2、Docker安装

本文档详细介绍了在CentOS系统上安装Docker的步骤,包括卸载旧版Docker、添加阿里云镜像仓库、安装Docker CE、启动Docker服务、验证安装及运行示例容器,并提供了卸载Docker的命令,确保用户能够顺利进行Docker的安装和使用。
摘要由CSDN通过智能技术生成

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值