Article directory
foreword
在CentOS7系统上离线跟在线两种方式安装docker
1. Network installation (yum installation)
1. Installation command
-y:安装途中不需要是否确认,直至安装成功~
yum install -y docker
2. Make sure the yum package is updated to the latest version
yum -y update
3. Check whether the docker list has been installed
yum list installed | grep docker
4. Configure Alibaba Cloud Mirroring
Edit configuration file:
vi /etc/docker/daemon.json
Add the following code:
{
"registry-mirrors": ["https://y0qd3iq.mirror.aliyuncs.com"]
}
2. No network installation
1. Download docker: docker offline installation package download address
The version downloaded in this article is:docker-18.06.3-ce.tgz
2. Install docker
and upload the docker offline installation package to the virtual machine:
通过cmd命令窗口上传(没有Xftp可以用以下方式):
scp D:\Downloads\docker-18.06.3-ce.tgz [email protected]:/usr/local/
图文详解(仅供参考):
虚拟机:
3. Unzip the installation package
tar -zxvf docker-18.06.3-ce.tgz
4. Move all the files in the docker after decompression to /usr/bin/
the directory
cp docker/* /usr/bin/
5. Register docker as a system service
vi /etc/systemd/system/docker.service
Insert the following configuration file
[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
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
6. Add execution permission to the configuration file
chmod +x /etc/systemd/system/docker.service
7. Reload the configuration file
systemctl daemon-reload
Three, operate docker
1. Start the docker service
systemctl start docker
2. Set docker to start automatically at boot
# 设置开机自启动
systemctl enable docker
# 关闭开机自启动
systemctl disable docker
2. View docker status
systemctl status docker
running状态标识docker正在运行。
3. Stop the docker service
systemctl stop docker
4. Uninstall docker
通过yum命令安装:
1. Find out the installed packages of docker
yum list installed | grep docker
2. Delete these packages by command
yum remove docker.x86_64 docker-client.x86_64 docker-common.x86_64 -y