Docker-(一).安装

https://www.jianshu.com/p/e6b946c79542

国内

移除掉旧的版本

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

删除所有旧的数据

rm -rf /var/lib/docker

安装依赖包

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

使用下面的命令安装稳定版仓库,即使安装最新体验版或者是测试版也需要稳定版仓库

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

可选:体验版和测试版默认是关闭的,你可以通过下面的命令打开,不打开也不影响稳定版的使用

打开体验版与测试版

yum-config-manager --enable docker-ce-edge
yum-config-manager --enable docker-ce-test

关闭体验版与测试版

yum-config-manager --disable docker-ce-edge
yum-config-manager --disable docker-ce-tes

配置缓存

yum makecache fast

安装指定版本的docker CE

yum list docker-ce --showduplicates | sort -r
yum install -y docker-ce-18.03.0.ce

安装最新稳定版本的docker

sudo yum install -y docker-ce

容器引擎配置镜像加速器

mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["http://hub-mirror.c.163.com"]
  "live-restore": true  #daemon服务不可用的时候,容器依旧保持运行状态
  #"graph": "/data/docker"
  #"insecure-registries": [],    # 设置docker的私有仓库地址
  #"bip": "",  #网络
  #"exec-opts": [],
}
EOF

启动docker引擎并设置开机启动

systemctl start docker
systemctl enable docker

配置当前用户对docker的执行权限

groupadd docker
gpasswd -a ${USER} docker
systemctl restart docker

国外版

remove old version

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

remove all docker data

sudo rm -rf /var/lib/docker

preinstall utils

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

add repository

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

make cache

sudo yum makecache fast

install the latest stable version of docker

sudo yum install -y docker-ce

start deamon and enable auto start when power on

sudo systemctl start docker
sudo systemctl enable docker

add current user

sudo groupadd docker
sudo gpasswd -a ${USER} docker
sudo systemctl restart docker
remove all docker data
sudo rm -rf /var/lib/docker

preinstall utils

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

add repository

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

make cache

sudo yum makecache fast

install the latest stable version of docker

sudo yum install -y docker-ce

start deamon and enable auto start when power on

sudo systemctl start docker
sudo systemctl enable docker

add current user

sudo groupadd docker
sudo gpasswd -a ${USER} docker
sudo systemctl restart docker
remove all docker data
sudo rm -rf /var/lib/docker

preinstall utils

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

add repository

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

make cache

sudo yum makecache fast

install the latest stable version of docker

sudo yum install -y docker-ce

start deamon and enable auto start when power on

sudo systemctl start docker
sudo systemctl enable docker

add current user

sudo groupadd docker
sudo gpasswd -a ${USER} docker
sudo systemctl restart docker

posted @ 2020-02-19 20:56  薄荷少年郎微微凉  阅读(182)  评论(0编辑  收藏  举报