centos7在线/离线安装docker
在线安装
安装yum-utils软件包
yum -y install yum-utils设置docker镜像源:
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo更新yum软件包索引:
yum makecache fast
yum repolist
# 查看所有仓库中的所有docker版本,并排序:
yum list docker-ce --showduplicates | sort -r安装docker:
yum -y install docker-ce docker-ce-cli containerd.io启动docker:
systemctl start docker
systemctl status docker | grep running设置开机自启
systemctl enable docker查看docker版本
docker -v测试docker:
docker run hello-world
docker images离线安装
下载docker离线安装包:
- 官网下载地址:https://download.docker.com/linux/static/stable/x86_64/
- 阿里云镜像下载地址:https://mirrors.aliyun.com/docker-ce/linux/static/stable/x86_64/
解压离线安装包:
tar -xf docker-24.0.6.tgz将docker相关命令复制至/usr/bin目录下:
cp -a docker/* /usr/bin/将docker注册为系统服务:
# vim /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP
$MAINPID
TimeoutStartSec=0
RestartSec=2
Restart=always
StartLimitBurst=3
StartLimitInterval=60s
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
Delegate=yes
KillMode=process
OOMScoreAdjust=-500
[Install]
WantedBy=multi-user.target重载配置文件并启动docker:
systemctl daemon-reload
systemctl start docker
systemctl status docker | grep running设置开机自启:
systemctl enable docker....以下步骤省略,参考在线安装
docker其它简单配置
配置docker镜像加速:
- 配置文件/etc/docker/daemon.json默认不存在
# mkdir -pv /etc/docker
# vim /etc/docker/daemon.json
{
    "registry-mirrors":["https://d8b3zdiw.mirror.aliyuncs.com"]
}systemctl daemon-reload
systemctl restart docker修改docker文件存储位置:
- docker文件默认存储位置为/var/lib/docker
docker info | grep  'Docker Root Dir'# mkdir -pv /data/docker
# vim /etc/docker/daemon.json
{
    "registry-mirrors":["https://d8b3zdiw.mirror.aliyuncs.com"],
    "data-root": "/data/docker"
}systemctl daemon-reload
systemctl restart docker
docker info | grep 'Docker Root Dir'
                        THE END
                    
                    
                    0
        
                        二维码        
                    
                                打赏            
                    
                        海报        
        
            
             
         
    centos7在线/离线安装docker
            
                在线安装
安装yum-utils软件包
yum -y install yum-utils
设置docker镜像源:
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/cen……            
             
                 
             
            
共有 0 条评论