docker 源码安装 指定目录位置

背景:有时候我们会在内网指定目录下安装docker ,废话不多说。看下面

docker 源码安装

省略:下载步骤了啊,网上一大堆

1 tar -zxf docker-20.10.17.tgz   #解压docker压缩包

2 cd docker                     #进入解压目录

3 cp -p docker/* /usr/bin       #把源码docker的命令拷贝到默认启动命令中,不多解释了。不明白的再学学基础

4 vi /usr/lib/systemd/system/docker.service  #建立快捷启动方法

[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target docker.socket
[Service]
Type=notify
EnvironmentFile=-/run/flannel/docker
WorkingDirectory=/usr/local/bin
ExecStart=/usr/bin/dockerd \
                -H tcp://0.0.0.0:4243 \
                -H unix:///var/run/docker.sock \
                --selinux-enabled=false \
                --log-opt max-size=1g
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=on-failure
[Install]
WantedBy=multi-user.target


5 systemctl daemon-reload  #重新加载一遍配置文件

6 systemctl start docker  #启动docker

7 mv /var/lib/docker /data/docker #默认是安装在根目录的,我们需要移动到指定的目录

8 ln -s /data/docker /var/lib/docker  #做一个软连接

9 systemctl restart docker  #重启docker就完成啦


接下来我们就可以开始玩转docker了,加油。

你可能感兴趣的:(docker,容器,运维)