Docker安装

https://docs.docker.com/engine/install/centos/

1、OS requirements

To install Docker Engine, you need a maintained version of CentOS 7 or 8. Archived versions aren’t supported or tested.

2、Uninstall old versions

 sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
 sudo yum install -y yum-utils

3、Install using the repository

Set up the repository 设置镜像仓库

 sudo yum install -y yum-utils

$ sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
阿里云
$ sudo yum-config-manager \
    --add-repo \
    https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

4、Install Docker Engine

 yum makecache fast

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

5、Start Docker.

 sudo systemctl start docker
Verify that Docker Engine is installed correctly by running the hello-world image.
 1 # docker version
 2 Client: Docker Engine - Community
 3  Version:           20.10.14
 4  API version:       1.41
 5  Go version:        go1.16.15
 6  Git commit:        a224086
 7  Built:             Thu Mar 24 01:49:57 2022
 8  OS/Arch:           linux/amd64
 9  Context:           default
10  Experimental:      true
11 
12 Server: Docker Engine - Community
13  Engine:
14   Version:          20.10.14
15   API version:      1.41 (minimum version 1.12)
16   Go version:       go1.16.15
17   Git commit:       87a90dc
18   Built:            Thu Mar 24 01:48:24 2022
19   OS/Arch:          linux/amd64
20   Experimental:     false
21  containerd:
22   Version:          1.5.11
23   GitCommit:        3df54a852345ae127d1fa3092b95168e4a88e2f8
24  runc:
25   Version:          1.0.3
26   GitCommit:        v1.0.3-0-gf46b6ba
27  docker-init:
28   Version:          0.19.0
29   GitCommit:        de40ad0
docker version
sudo docker run hello-world
 1 Unable to find image 'hello-world:latest' locally
 2 latest: Pulling from library/hello-world
 3 2db29710123e: Pull complete 
 4 Digest: sha256:bfea6278a0a267fad2634554f4f0c6f31981eea41c553fdf5a83e95a41d40c38
 5 Status: Downloaded newer image for hello-world:latest
 6 
 7 Hello from Docker!
 8 This message shows that your installation appears to be working correctly.
 9 
10 To generate this message, Docker took the following steps:
11  1. The Docker client contacted the Docker daemon.
12  2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
13     (amd64)
14  3. The Docker daemon created a new container from that image which runs the
15     executable that produces the output you are currently reading.
16  4. The Docker daemon streamed that output to the Docker client, which sent it
17     to your terminal.
18 
19 To try something more ambitious, you can run an Ubuntu container with:
20  $ docker run -it ubuntu bash
21 
22 Share images, automate workflows, and more with a free Docker ID:
23  https://hub.docker.com/
24 
25 For more examples and ideas, visit:
26  https://docs.docker.com/get-started/
hello world

# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 6 months ago 13.3kB

Uninstall Docker Engine

  • 1、Uninstall the Docker Engine, CLI, and Containerd packages:

  sudo yum remove docker-ce docker-ce-cli containerd.io

  • 2、Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:

   sudo rm -rf /var/lib/docker $ sudo rm -rf /var/lib/containerd

阿里云镜像加速

# mkdir -p /etc/docker

# tee /etc/docker/daemon.json <<-'EOF'
> {"registry-mirrors":["https://qiyb9988.mirror.aliyuncs.com"]}
> EOF

# systemctl daemon-reload
# systemctl restart docker

posted on 2022-04-09 20:44  HelonTian  阅读(109)  评论(0编辑  收藏  举报