安装docker和docker-compose

环境:centos7,参考官方文档:https://docs.docker.com/insta...

第一步:删除旧版本和相关依赖,运行命令:

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

第二步,安装依赖,命令:

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

第三步,配置稳定的repositories,命令:

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

第四步,安装docker,命令:

yum install docker-ce docker-ce-cli containerd.io

完成后通过docker version命令看到docker信息:
安装docker和docker-compose

启动:systemctl start docker
开机启动:systemctl enable docker

接下来安装docker-compose,运行命令:

curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

给docker-compose执行权限,运行命令:

chmod +x /usr/local/bin/docker-compose

检查,运行docker-compose --version,如下:

安装docker和docker-compose

至此,docker和docker-compose安装成功;

docker参考文档:
https://docs.docker.com/get-s...

docker-compose文档:
https://docs.docker.com/compo...

相关推荐