docker安装详细过程
ubuntu安装docker
我这里用mobaxterm远程连接安装的,如何远程连接在上一篇文章
1、解压
tar -zxvf docker-19.03.5.tgz
-
拷贝文件至bin下
chmod +x docker/* (增加x权限)
cp docker/* /usr/local/bin(拷贝文件到bin下)
-
创建服务文件
cat > /usr/lib/systemd/system/docker.service <<"EOF"
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.io
[Service]
Environment="PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin"
EnvironmentFile=-/run/flannel/docker
ExecStart=/usr/local/bin/dockerd --graph=/var/lib/docker --log-level=error $DOCKER_NETWORK_OPTIONS
ExecReload=/bin/kill -s HUP $MAINPID
Restart=on-failure
RestartSec=5
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Delegate=yes
KillMode=process
[Install]
WantedBy=multi-user.target
EOF
- 修改docker挂载路径,默认为/var/lib/docker,建议选择最大数据盘,比如最大数据盘为/data
sed -i s#/var/lib/docker#/opt/data/docker#g /usr/lib/systemd/system/docker.service
注:注意文件夹位置,确认路径的文件夹是否都有,我就是新建的system文件夹、data文件
-
启动docker:
systemctl daemon-reload
systemctl restart docker
systemctl enable docker -
检验是否启动:
systemctl status docker
docker info