当前位置:   article > 正文

Docker——下载与安装_docker下载

docker下载

一、有网的情况下安装

# 首先,使用yum remove docker* 移除之前安装的docker
yum remove docker*
# 配置yum源
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 下面这个命令是将软件包信息提前在本地缓存一份,用来提高搜索安装软件的速度
sudo yum makecache fast
# 安装docker
sudo yum install -y docker-ce docker-ce-cli containerd.io
# 启动Docker服务
systemctl start docker
# 设置开机自动启动
systemctl enable docker
# 测试
docker run hello-world
# 卸载的命令
sudo yum remove docker-ce docker-ce-cli containerd.io
# 软件卸载后,Docker默认的工作路径是/var/lib/docker 需要执行rm命令把这个工作路径删除
rm -rf /var/lib/docker
# 阿里云镜像加速配置
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://g090nq5l.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
  • 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

在这里插入图片描述

二、无网络环境下安装docker

1、下载符合操作系统的docker版本

2、解压到指定目录下

tar -zxvf docker-23.0.1.tgz
  • 1

3、解压的docker文件夹全部移动至/usr/bin目录

cp -p docker/* /usr/bin
  • 1

4、将docker注册为系统服务

① 在/usr/lib/systemd/system/目录下,创建docker.service文件

vim  /etc/systemd/system/docker.service
  • 1

② 编辑docker.service文件
注:以下内容中 --insecure-registry=192.168.3.10 此处改为你自己服务器ip。

[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 --selinux-enabled=false --insecure-registry=192.168.3.10
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
  • 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

5、重启生效

重启守护进程

# 给予权限
chmod 777 /etc/systemd/system/docker.service
# 重启守护进程
systemctl daemon-reload
# 启动docker
systemctl start docker
# 查看docker状态
systemctl status docker
# 设置开机自启动
systemctl enable docker
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/616399
推荐阅读
相关标签
  

闽ICP备14008679号