Table of contents
-
- 1. Offline installation
-
- 1. CentOS offline installation
-
- 1. Download address
- Two, start the installation
-
- 1. Unzip the compressed package
- 2. Copy the decompressed file to the /usr/bin directory
- 3. Register the docker service and start it up
- 4. Set permissions for the service file
- 5. Reload configuration
- 6. Set docker to start at boot
- 7. Start docker
- 8. Check the status of the container
- 9. Check whether the installed version is correct
- 2. Ubuntu offline installation
-
- 1. Download address
- Two, start the installation
-
- 1. Unzip the compressed package
- 2. Copy the decompressed file to the /usr/bin directory
- 3. Register the docker service and start it up
- 4. Set permissions for the service file
- 5. Reload configuration
- 6. Set docker to start at boot
- 7. Start docker
- 8. Check the status of the container
- 9. Check whether the installed version is correct
- 2. Online installation
- 3. Create a docker user group
- 4. Test whether Docker is installed correctly
1. Offline installation
1. CentOS offline installation
1. Download address
1. Select the model of the system, select linux-CentOS
2. Upload the file to the CentOS server
rz
#选择文件
Two, start the installation
1. Unzip the compressed package
tar -zxvf docker-20.10.9.tgz
2. Copy the decompressed file to the /usr/bin directory
cp docker/* /usr/bin/
Copy the decompressed files to the /usr/bin directory through the command .
3. Register the docker service and start it up
Create a docker.service file in /etc/systemd/system
the directory to register the docker service and boot
#创建一个docker.service文件
vi /etc/systemd/system/docker.service
#内容如下:
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/dockerd --selinux-enabled=false --insecure-registry=127.0.0.1
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
4. Set permissions for the service file
chmod 777 /etc/systemd/system/docker.service
5. Reload configuration
systemctl daemon-reload
6. Set docker to start at boot
systemctl enable docker.service
7. Start docker
systemctl start docker
8. Check the status of the container
systemctl status docker
9. Check whether the installed version is correct
docker -v
2. Ubuntu offline installation
1. Download address
1. Select the model of the system, select linux-Ubuntu
2. Upload the file to the Ubuntu server
#选择文件。
rz
#有可能ubuntu系统没有此功能,需要下载,见图一。
apt install lrzsz
Two, start the installation
1. Unzip the compressed package
tar -zxvf docker-20.10.9.tgz
2. Copy the decompressed file to the /usr/bin directory
cp docker/* /usr/bin/
Copy the decompressed files to the /usr/bin directory through the command .
3. Register the docker service and start it up
Create a docker.service file in /etc/systemd/system
the directory to register the docker service and boot
#创建一个docker.service文件
vi /etc/systemd/system/docker.service
#内容如下:
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/dockerd --selinux-enabled=false --insecure-registry=127.0.0.1
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
4. Set permissions for the service file
chmod 777 /etc/systemd/system/docker.service
5. Reload configuration
systemctl daemon-reload
6. Set docker to start at boot
systemctl enable docker.service
7. Start docker
systemctl start docker
8. Check the status of the container
systemctl status docker
9. Check whether the installed version is correct
docker -v
2. Online installation
1. CentOS online installation
1. Preconditions
1. Check the system kernel
Note: Generally, the latest version can ignore this step.
Docker needs to be installed on the 64-bit version of CentOS. In addition, you also need to ensure that the minimum version of your CentOS kernel is not lower than 3.10, and the 3.10 minor version and update maintenance version are also available.
uname -r
2. Uninstall the old version
Older versions of Docker are called docker
or docker-engine
, uninstall older versions with the following command:
yum install apt
sudo apt-get remove docker docker-engine docker.io
3. Uninstall the old version and report an error
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock-frontend
Two, start the installation
1. Use script to install automatically
In order to simplify the installation process in the test or development environment, Docker official provides a set of convenient installation scripts, which can be used to install on the Ubuntu system, and can also be installed using domestic sources through the --mirror option:
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
Note: If the warning shown in the figure below appears, there is no need to worry, and you can continue to the next step.
5. Start Docker
sudo systemctl enable docker
sudo systemctl start docker
Note: Here is a prompt to execute /lib/systemd/systemd-sysv-install enable docker
this command. Then run it again .
6. Check whether the installation is successful
docker compose version
docker --version
docker version
1. Ubantu online installation
1. Preconditions
1. Check the system kernel
Note: Generally, the latest version can ignore this step.
Docker needs to be installed on a 64-bit version of Ubuntu. In addition, you also need to ensure that the minimum version of your Ubuntu kernel is not lower than 3.10, and the 3.10 minor version and update maintenance version are also available.
uname -r
2. Uninstall the old version
Older versions of Docker are called docker
or docker-engine
, uninstall older versions with the following command:
sudo apt-get remove docker docker-engine docker.io
3. Uninstall the old version and report an error
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock-frontend
Two, start the installation
1. The default version number is installed
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
2. Add GPG
the key of the software source
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
3. Add Docker software source
sources.list
Add Docker repository to .
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
3. Update the apt package cache and installdocker-ce
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
4. Automatically install using scripts
In order to simplify the installation process in the test or development environment, Docker official provides a set of convenient installation scripts, which can be used to install on the Ubuntu system, and can also be installed using domestic sources through the --mirror option:
curl -fsSL get.docker.com -o get-docker.sh
sudo sh get-docker.sh --mirror Aliyun
Note: If the warning shown in the figure below appears, there is no need to worry, and you can continue to the next step.
5. Start Docker
sudo systemctl enable docker
sudo systemctl start docker
Note: Here is a prompt to execute /lib/systemd/systemd-sysv-install enable docker
this command. Then run it again .
6. Check whether the installation is successful
docker compose version
docker --version
docker version
3. Create a docker user group
1. Create a docker group
sudo groupadd docker
2. Add the current user to the docker group
sudo usermod -aG docker $USER
4. Test whether Docker is installed correctly
docker run --rm hello-world