灬小肥狗灬
1
灬小肥狗之家灬

【随笔记录】二进制方式离线安装docker

创建docker组并将普通用户加入docker组

groupadd -g 980 docker
usermod -aG docker alfd

检查是否成功创建并添加

cat /etc/group | grep docker

解包离线docker二进制文件包,并将docker目录下的文件复制到/usr/bin/下

tar zxvf docker*
cp docker/* /usr/bin/

在/etc/systemd/system下创建docker.service文件,并给该文件赋权755

vi /etc/systemd/system/docker.service
chmod 755 /etc/systemd/system/docker.service

在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
Group=docker
# 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 --selinux-enabled=false
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

重载systemctl配置文件、设置开机自启并启动docker,并检查启动是否正常

systemctl daemon-reload
systemctl enable docker
systemctl start docker
systemctl status docker

切换到普通用户,验证能否使用docker

su - alfd
docker ps
没有标签
首页      Uncategorized      【随笔记录】二进制方式离线安装docker

灬小肥狗灬

文章作者

发表回复

textsms
account_circle
email

13 − 7 =

灬小肥狗之家灬

【随笔记录】二进制方式离线安装docker
创建docker组并将普通用户加入docker组 groupadd -g 980 docker usermod -aG docker alfd 检查是否成功创建并添加 cat /etc/group | grep docker 解包离线docker二进制文件包,并将docker…
扫描二维码继续阅读
2022-11-14