安装

  1. curl -fsSL get.docker.com -o get-docker.sh
  2. sh get-docker.sh --mirror Aliyun
  3. # 报错
  4. package docker-ce-3:19.03.14-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed
  5. yum install https://download.docker.com/linux/fedora/30/x86_64/stable/Packages/containerd.io-1.2.6-3.3.fc30.x86_64.rpm

yum 安装

  1. yum -y update # 更新yum 源
  2. yum install -y epel-release # 安装epel 源
  3. yum clean all # 清除yum 缓存
  4. yum install docker-io -y # 安装docker

修改默认镜像存储位置

  1. systemctl show --property=FragmentPath docker # 查看服务配置位置
  2. yum -y install vim*
  3. vim /usr/lib/systemd/system/docker.service
  4. ExecStart=/usr/bin/dockerd --graph=/mnt/data/docker \ # 修改存储路径 为/mnt/data/docker

启动docker

  1. systemctl daemon-reload # 配置生效
  2. systemctl restart docker # 启动docker
  3. systemctl enable docker.service # 设置Docker 开机启动

安装Docker Compose

  1. sudo curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  2. sudo chmod +x /usr/local/bin/docker-compose