服务器之家:专注于VPS、云服务器配置技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Ubuntu - Ubuntu 20.04 上安装和使用 Docker的详细过程(安装包)

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

2022-08-09 10:28久末丶 Ubuntu

这篇文章主要介绍了Ubuntu 20.04 上安装和使用 Docker的详细过程(安装包),本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

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

一、解压文件

?
1
tar -xzvf docker-19.03.0.tgz

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

?
1
cp docker/* /usr/bin/

三、加入系统文件

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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

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

五、Docker配置文件

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

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

六、重启Docker

?
1
systemctl restart docker

七、检查Docker是否安装成功

?
1
docker --version

八、总结

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

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

到此这篇关于Ubuntu 20.04 上安装和使用 Docker的详细过程(安装包)的文章就介绍到这了,更多相关Ubuntu 20.04使用 Docker内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!

原文链接:https://www.cnblogs.com/jiumo/p/15958437.html

延伸 · 阅读

精彩推荐