1. 程式人生 > >Centos安裝docker#避免很多坑

Centos安裝docker#避免很多坑

config 17. onf app available conf 很多 python 加速器

采用yum方式安裝

安裝:

step 1: 安裝必要的一些系統工具

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

Step 2: 添加軟件源信息

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

Step 3: 更新並安裝 Docker-CE

yum makecache fast
yum -y install docker-ce

Step 4: 開啟Docker服務

service docker start
安裝指定版本的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)

yum -y install docker-ce-[VERSION]
安裝校驗:
docker version
配置加速器:(適用於此版本)
systemctl enable docker(產生下面的文件)

vim /etc/systemd/system/multi-user.target.wants/docker.service
將ExecStart=/usr/bin/dockerd
修改為
ExecStart=/usr/bin/dockerd --registry-mirror=https://registry.docker-cn.com
此為阿裏雲加速器,執行 ps -ef | grep docker 或者docker info 也可以看見加速ok
systemctl daemon-reload
systemctl start docker

安裝docker-compose

需要先安裝企業版linux附加包(epel)
$ yum -y install epel-release
安裝pip
$ yum -y install python-pip
更新pip
$ pip install --upgrade pip
//國內原加速
$ pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip
安裝docker-compose
$ pip install docker-compose
//國內原加速
$ pip install -i https://pypi.tuna.tsinghua.edu.cn/simple docker-compose
查看docker-compose版本信息
$ docker-compose --version

Centos安裝docker#避免很多坑