Signature: But do good deeds, don't ask about the future.
Article directory
foreword
Document the process of installing Docker on a fresh virtual machine.
Preconditions:
- A little basic knowledge of Linux
- CentOS7 system
- 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.
2.Docker official website
Docker official website address: https://www.docker.com/
3.Docker Documentation
Docker document address: https://docs.docker.com/
Two, Docker installation
Connect to the local virtual machine
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/
1. Uninstall the old docker on the server
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
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
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
5. Start docker
sudo systemctl start docker
6. run hello world
sudo docker run hello-world
Seeing this means that the docker installation was successful.
3. Uninstall docker
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.