欢迎来到代码驿站!

当前位置:首页 >

Ubuntu 20.04 上安装和使用 Docker的详细过程(安装包)

时间:2022-09-05 10:53:18|栏目:|点击:

安装前将所有的软件包上传到系统的/opt路径,所有的操作都在/opt目录下

一、解压文件

tar -xzvf docker-19.03.0.tgz

二、拷贝解压后的文件到/usr/bin/下面

cp docker/* /usr/bin/

三、加入系统文件

cat >/etc/systemd/system/docker.service <<-EOF
[Unit]
Description=Docker Application Container Engine
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 -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
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
EOF

四、启动Docker

systemctl daemon-reload && systemctl start docker && systemctl enable docker.service

五、Docker配置文件

编辑daemon.json文件输入以下内容

vim /etc/docker/daemon.json
{
    "log-driver":"json-file",
    "log-opts":{
        "max-size" :"10m","max-file":"4"
    },
    "registry-mirrors": ["https://6kx4zyno.mirror.aliyuncs.com"]
}

六、重启Docker

systemctl restart docker 

七、检查Docker是否安装成功

docker --version

八、总结

我们已经向你展示如何在 Ubuntu 20.04 机器上安装 Docker。

想要学习更多关于 Docker 的信息,查阅官方 Docker 文档

上一篇:带参数的sql和不带参数的sql存储过程区别第1/2页

栏    目:

下一篇:Lua入门学习笔记

本文标题:Ubuntu 20.04 上安装和使用 Docker的详细过程(安装包)

本文地址:http://www.codeinn.net/misctech/212865.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有