二进制包安装Docker
最近公司用docker部署项目,由于是内网环境,安装docker不能yum安装,只能rmp或者二进制包安装,但是rmp安装又有许多的依赖包要安装,而且要解决依赖冲突问题;所以就选择了 二进制安装Docker 方式。网上查了很多资料,踩了很多坑,下面记录本人亲测有效的安装方式、步骤。
一、准备 Docker CE 二进制包
这里使用docker-20.10.21版本。
-
下载地址:
链接: docker-20.10.21.tgz -
服务器下载命令:
wget -c https://download.docker.com/linux/static/stable/x86_64/docker-20.10.21.tgz
二、解压.tgz包
root用户操作:
tar -zxvf docker-20.10.21.tgz
改变权限:
chown root:root docker/*
三、复制二进制文件到/usr/bin/目录
cp -p docker/* /usr/bin/
四、创建用户组
groupadd docker
五、配置相关服务配置文件
有三个配置文件:docker.service 、docker.socket、 containerd.service。
docker.service配置文件:
touch docker.service
vim 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
# 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
docker.socket配置文件:
touch docker.socket
vim docker.socket
[Unit]
Description=Docker Socket for the API
PartOf=docker.service
[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker
[Install]
WantedBy=sockets.target
containerd.service配置文件:
touch containerd.service
vim containerd.service
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target
[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/bin/containerd
Type=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5
# 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
LimitNOFILE=infinity
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
OOMScoreAdjust=-999
[Install]
WantedBy=multi-user.target
六、拷贝配置文件到指定目录
sudo cp docker.socket /etc/systemd/system
sudo cp docker.service /etc/systemd/system
sudo cp containerd.service /etc/systemd/system
添加可执行权限:
chmod a+x /etc/systemd/system/docker.service
chmod a+x /etc/systemd/system/docker.socket
chmod a+x /etc/systemd/system/containerd.service
七、启动 dockerd 服务进程
systemctl enable docker.service
八、启动docker服务
systemctl start docker.service
检验是否启动成功
通过运行镜像“hello-world”来验证 Docker Engine 是否正确安装:文章来源:https://www.toymoban.com/news/detail-733543.html
sudo docker run hello-world
文章来源地址https://www.toymoban.com/news/detail-733543.html
安装完毕!
到了这里,关于二进制包安装Docker(亲测有效)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!