ubuntu离线安装
- 下载docker安装包,下载地址 https://download.docker.com/linux/static/stable/x86_64/
- 将下载的 docker-26.1.3.tgz放在tmp目录下,解压缩
tar -zxvf docker-26.1.3.tgz
- 将解压缩后的目录,全部拷贝到 /usr/bin目录下(特别提醒,不能将压缩包,拷贝到 /usr/bin 目录下再解压,会不生效)
cp -p docker/* /usr/bin
# 遇到提示,全部overwrite即可,如下图
- 将docker注册为系统服务
- 将docker.service文件放到 /usr/lib/systemd/system/ 目录下
- 将docker.socket文件放到 /usr/lib/systemd/system/ 目录下
可以从在线安装docker的目录下,拷贝这两个文件,可以直接使用,简书插入不了附件,以下是这两个文件的内容
docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service containerd.service time-set.target
Wants=network-online.target containerd.service
Requires=docker.socket
[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 -H fd:// --containerd=/run/containerd/containerd.sock
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutStartSec=0
RestartSec=2
Restart=always
# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3
# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity
# 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
OOMScoreAdjust=-500
[Install]
WantedBy=multi-user.target
docker.socket
[Unit]
Description=Docker Socket for the API
[Socket]
# If /var/run is not implemented as a symlink to /run, you may need to
# specify ListenStream=/var/run/docker.sock instead.
ListenStream=/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker
[Install]
WantedBy=sockets.target
- 给系统增加一个docker组
groupadd docker
- 重启守护进程
systemctl daemon-reload
- 启动docker
systemctl start docker
- 设置docker开启启动
systemctl enable docker
- 安装docker-compose
- 从 https://github.com/docker/compose/releases 下载linux环境包 docker-compose-Linux-x86_64
- 将下载的文件,拷贝到目标机器的 /usr/local/bin/ 目录下,将docker-compose-Linux-x86_64文件重命名为 docker-compse
- 给 docker-compose 文件授权 chmod +x /usr/local/bin/docker-compose
- 测试 docker-compse -v 即可以查看对应版本信息
centos离线安装
arm64离线安装(步骤与ubuntu一致,有几个点需要注意)
- 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
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
- 装好之后,pull镜像的时候如果出现报错:
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: container_linux.go:318: starting container process caused "permission denied": unknown
解决方法:执行命令 yum remove podman