1.下载docker的离线安装包
链接: https://pan.baidu.com/s/1beDBIYw-8IjJj5syGnHiZA 提取码: 8888 复制这段内容后打开百度网盘手机App,操作更方便哦
2.将二进制文件:docker-20.10.19.tgz 拖入服务器目录/home/admin/解压
tar -zxvf docker-20.10.19.tgz
3.将docker文件移动到可执行文件目录下
mv /home/admin/docker/* /usr/bin
4新建配置docker.service文件
vim /etc/systemd/system/docker.service
5…添加docker相关配置文本
#文本内容开始
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
#文本内容结束
6添加文件权限
chmod +x /etc/systemd/system/docker.service
7重加载unit配置文件
systemctl daemon-reload
8启动Docker
systemctl start docker
9.设置docker开机自启
systemctl enable docker.service
10.docker常用命令
查看docker详情
docker info
查看docker 镜像
docker images
查看docker所有容器
docker ps -a
查看镜像
docker search 镜像名称 #opt自行修改
停止容器
docker stop 容器ID或容器名称
删除容器
docker rm -f 容器ID或容器名称
重启容器
docker restart 容器ID或容器名称
进入容器
docker exec -it 容器ID或容器名称 /bin/bash
docker启动所有容器
docker ps -a -q:列出所有容器的ID,包括停止的容器。
docker start $(docker ps -a -q)
docker拉取镜像
docker pull 镜像名称