centos7 install docker

1、uninstall old docker

  sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

2、install require packages

  sudo yum install -y yum-utils \
                      device-mapper-persistent-data \
                      lvm2

3、update yum repo

  sudo yum-config-manager \
        --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

4、update yum cache

  sudo yum makecache fast

5、install docker-ce

  sudo yum install docker-ce

 

可能会出现的错误:

Error:
Problem: package docker-ce-3:19.03.8-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed

此时需要安装新版containerd.io

dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm

 6、start docker service

  sudo systemctl start docker

7、verify docker

  sudo docker run hello-world

ps: 参考官方文档 v18.09

# docker镜像的默认存储路径是/var/lib/docker
# 配置文件地址  /usr/lib/systemd/system/docker.service
# 在ExecStart行加上 --graph /docker/data

# 启用docker远程连接
# 配置文件地址 /usr/lib/systemd/system/docker.service
# 在ExecStart行加上 -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock

ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --graph /docker/data -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock

# 修改配置后需要重启docker
systemctl daemon-reload
systemctl restart docker
# 安装指定版本的Docker-CE:
# Step 1: 查找Docker-CE的版本:
# yum list docker-ce.x86_64 --showduplicates | sort -r
#   Loading mirror speeds from cached hostfile
#   Loaded plugins: branch, fastestmirror, langpacks
#   docker-ce.x86_64            17.03.1.ce-1.el7.centos            docker-ce-stable
#   docker-ce.x86_64            17.03.1.ce-1.el7.centos            @docker-ce-stable
#   docker-ce.x86_64            17.03.0.ce-1.el7.centos            docker-ce-stable
#   Available Packages
# Step2: 安装指定版本的Docker-CE: (VERSION例如上面的17.03.0.ce.1-1.el7.centos)
# sudo yum -y install docker-ce-[VERSION]

安装  docker-compose

# 拉取github上的docker-compose
# https://github.com/docker/compose/releases?after=1.26.0-rc1
curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

# 赋予执行权限
chmod +x /usr/local/bin/docker-compose

# 查看版本
docker-compose --version

其他Docker链接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值