安装一些必要的系统工具:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
添加软件源信息:
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
更新 yum 缓存:
sudo yum makecache fast
安装 Docker-ce:(企业版 社区版)
sudo yum -y install docker-ce
启动 Docker 后台服务
sudo systemctl start docker
设置自启动
sudo systemctl enable docker
测试运行 hello-world
docker run hello-world
Docker-Compose
二进制文件安装
curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
如果需要安装其他版本的话,请修改上面命令中的版本号。
赋予二进制文件可执行权限
chmod +x /usr/local/bin/docker-compose
根据自己的情况决定是否安装命令补全功能
yum install bash-completion
curl -L [https://raw.githubusercontent.com/docker/compose/1.16.1/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose](https://raw.githubusercontent.com/docker/compose/1.16.1/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose)
重新登陆后就生效了
docker-compose
build config down exec images logs port pull restart run start top up
bundle create events help kill pause ps push rm scale stop unpause version
测试是否安装成功
docker-compose --version
卸载docker-compose
sudo rm /usr/local/bin/docker-compose
pip yum 安装
yum install python-pip
pip install docker-compose
测试:
docker-compose --version
卸载docker-compose
如果通过Python pip工具安装的,则执行如下命令删除:
sudo pip uninstall docker-compose