centos7 docker & docker-compose

删除旧版本

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

安装依赖包

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

添加镜像源

sudo yum-config-manager \ --add-repo \ https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo

更新 yum 软件源缓存,并安装 docker-ce

sudo yum makecache fast
sudo yum install docker-ce

启动 Docker CE

systemctl  start docker.service
systemctl  enable docker.service

docker官方安装方式

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


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

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

sudo yum-config-manager --disable docker-ce-nightly

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

sudo systemctl start docker

安装docker-compose

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

添加权限

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

常用操作

镜像
 docker images
 docker images -a
 docker rmi [id]
 
容器
 docker ps
 docker ps -a
 docker rm [id]

批量删除容器:

docker   container   rm  $(docker  container  ls   -a  -q)

批量删除镜像:

docker  image   rm   $(docker  image  ls   -a  -q)

你可能感兴趣的:(centos7 docker & docker-compose)