docker安装和卸载

内容分享2个月前发布
0 0 0

1.卸载老版本

 $ sudo yum remove docker 
                  docker-client 
                  docker-client-latest 
                  docker-common 
                  docker-latest 
                  docker-latest-logrotate 
                  docker-logrotate 
                  docker-engine

2.安装需要的安装包

yum install -y yum-utils

此时出现一个问题 Another app is currently holding the yum lock; waiting for it to exit

解决:强制结束进程

rm -rf /var/run/yum.pid

3.设置镜像仓库
官方:

yum-config-manager 
    --add-repo 
    https://download.docker.com/linux/centos/docker-ce.repo

一般使用阿里云镜像:

yum-config-manager 
    --add-repo 
    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

4.更新yum软件包索引

yum makecache fast

5.安装docker(最新版本)

yum install docker-ce docker-ce-cli containerd.io

6.启动服务

systemctl start docker

7.查看docker version

8.运行 hello world

[root@VM-16-17-centos ~]# docker run hello-world
Unable to find image  hello-world:latest  locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:97a379f4f88575512824f3b352bc03cd75e239179eea0fecc38e597b2209f49a
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/

[root@VM-16-17-centos ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
hello-world   latest    feb5d9fea6a5   4 months ago   13.3kB

9.卸载docker

# 卸载镜像
yum remove docker-ce docker-ce-cli containerd.io

#删除目录文件
rm -rf /var/lib/docker
rm -rf /var/lib/containerd

© 版权声明

相关文章

暂无评论

none
暂无评论...