Install Docker on a virtual machine

Signature: But do good deeds, don't ask about the future.


foreword

Document the process of installing Docker on a fresh virtual machine.
Preconditions:

  1. A little basic knowledge of Linux
  2. CentOS7 system
  3. Use the ssh connection tool to connect to the server for operation

1. Getting to know Docker first

1. What is Docker?

Docker is an open source application container engine that allows developers to package their applications and dependencies into a portable image, and then publish it to any popular Linux or Windows operating system machine, and can also implement virtualization. Containers use a sandbox mechanism completely, and there will be no interfaces between them.
insert image description here

2.Docker official website

Docker official website address: https://www.docker.com/
insert image description here

3.Docker Documentation

Docker document address: https://docs.docker.com/
insert image description here

Two, Docker installation

Connect to the local virtual machine
insert image description here
to view the environment of the virtual machine

uname -r
3.10.0-1160.el7.x86_64

The system kernel is above 3.10

cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

System version CentOS 7

Open the official docker help document
Docker install centos address: https://docs.docker.com/engine/install/centos/
insert image description here

1. Uninstall the old docker on the server

insert image description here
Uninstall command:

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

2. Install the required packages

insert image description here
Download the basic package

sudo yum install -y yum-utils  

3. Set up mirror warehouse

It is recommended to use Alibaba Cloud's mirror warehouse address, which is better than foreign blocks

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

4. Install the Docker engine

insert image description here

sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

5. Start docker

insert image description here

sudo systemctl start docker

6. run hello world

insert image description here

sudo docker run hello-world

insert image description here
Seeing this means that the docker installation was successful.

3. Uninstall docker

insert image description here
1. Remove download dependencies

sudo yum remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras

2. Delete the docker folder

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

Summarize

The above is the whole process of installing docker on a new server according to the official docker documentation. Please correct me if there are any mistakes or shortcomings.

Guess you like

Origin blog.csdn.net/YangCunle/article/details/128956502