docker 小记

一、卸载

  1. 查看当前版本
bash 复制代码
docker -v
  1. 如果有,先停止docker
bash 复制代码
systemctl stop docker
  1. 如果是yum安装,卸载方式为
bash 复制代码
#已防版本冲突,直接卸载
yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

如果为二进制离线安装,则卸载方式

删除docker配置文件目录

bash 复制代码
rm -rf /etc/docker

删除docker service文件目录

bash 复制代码
rm -rf /etc/systemd/system/docker.service

bash 复制代码
rm -rf /usr/lib/systemd/system/docker.service

删除docker部署目录

bash 复制代码
# 如果配置文件中指定了docker-root配置项,则删除该配置项对应的目录
rm -rf /home/docker_data
# 如果配置项中未指定docker-root配置项,则docker会被部署到/var/lib/docker目录下
rm -rf /var/lib/docker

卸载docker存储库

bash 复制代码
rm -rf /etc/yum.repos.d/docker-ce.repo

重启服务

bash 复制代码
reboot

二、安装

二进制安装

  1. 阿里云下载安装包:https://mirrors.aliyun.com/docker-ce/linux/static/stable/x86_64/

  2. 解压,移动

bash 复制代码
tar -zvxf docker-26.0.0.tgz
cp docker/* /usr/bin/
  1. 注册服务,新建 docker.service 文件
bash 复制代码
[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
  1. 将 docker.service 拷贝到
bash 复制代码
cp docker.service /usr/lib/systemd/system/
  1. 重新加载配置文件
bash 复制代码
systemctl daemon-reload
  1. 启动docker
bash 复制代码
systemctl start docker
  1. 查看docker状态
bash 复制代码
systemctl status docker
  1. 设置开机自启
bash 复制代码
systemctl enable docker

注意:如果启动docker提示"Failed to execute operation: Bad message",可能复制docker.service文件时,Unit 变成了 t],又或者ExecStart 写成Execstart。

配置镜像参考:https://blog.csdn.net/u014390502/article/details/143472743

比如:https://docker.tbedu.top/

一. docker命令

二. docker 存储

三. docker 网络

四. docker compose

五. dockerfile

相关推荐
RisunJan3 小时前
Linux命令-rlogin(远程登录)
linux·运维
深圳恒讯3 小时前
菲律宾云服务器与传统VPS的架构差异
运维·服务器·架构
蓝天下的守望者3 小时前
svt_apb_if里的宏定义问题
运维·服务器·数据库
小林ixn3 小时前
从“玩具工具”到“跨语言利器”:MCP 协议实战解析
运维·服务器·网络
小顿的企业观察4 小时前
中企出海战略规划,正在从“走出去”转向“走进去”
大数据·运维·人工智能·产品运营·制造
数智化转型推荐官5 小时前
2026统一身份管理系统五大发展趋势解读
java·运维·微服务
看菜鸡互5 小时前
探索用 SlideML 让大模型生成 PPT 的实验方法
java·运维
liguojun20257 小时前
篮球馆自动计时收费系统:从规则配置到自动结算的全流程拆解
java·大数据·运维·人工智能·物联网·1024程序员节
Promise微笑7 小时前
红外分辨率 160×120、320×240、384×288 与 640×480实战选型指南
大数据·运维·人工智能·物联网
云飞云共享云桌面8 小时前
单机建模卡顿运维繁琐!中小型机械制造厂云飞云 3D 云桌面落地
运维·服务器·网络·3d·自动化·电脑·负载均衡