使用官方安装脚本自动安装
安装命令如下:
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
也可以使用国内 daocloud 一键安装命令:
curl -sSL https://get.daocloud.io/docker | sh
设置docker 加速器
sudo curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://b81aace9.m.daocloud.iosudo systemctl restart docker
安装相关依赖
sudo yum -y install epel-releasesudo yum -y install python-pipsudo yum clean all
安装docker-compose
sudo pip install docker-compose
安装docker-compose 可能遇到的问题
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Collecting PyYAML<6,>=3.10Using cached PyYAML-5.3.1.tar.gz (269 kB)ERROR: Command errored out with exit status 1:command: /usr/bin/python2 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-rrvkCa/pyyaml/setup.py'"'"'; __file__='"'"'/tmp/pip-install-rrvkCa/pyyaml/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-52CudBcwd: /tmp/pip-install-rrvkCa/pyyaml/Complete output (19 lines):Traceback (most recent call last):File "<string>", line 1, in <module>File "/tmp/pip-install-rrvkCa/pyyaml/setup.py", line 314, in <module>python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*',File "/usr/lib64/python2.7/distutils/core.py", line 112, in setup_setup_distribution = dist = klass(attrs)File "/tmp/pip-install-rrvkCa/pyyaml/setup.py", line 112, in __init___Distribution.__init__(self, attrs)File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 269, in __init___Distribution.__init__(self,attrs)File "/usr/lib64/python2.7/distutils/dist.py", line 287, in __init__self.finalize_options()File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 302, in finalize_optionsep.load()(self, ep.name, value)File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2443, in loadreturn self.resolve()File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2453, in resolveraise ImportError(str(exc))ImportError: 'module' object has no attribute 'check_specifier'---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
解决方法:
执行
pip install --upgrade pip python -m pip install --upgrade setuptools
安装成功
查看安装版本信息
[root@test6 ~]# docker-compose version
/usr/lib64/python2.7/site-packages/cryptography/__init__.py:39: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in a future release.CryptographyDeprecationWarning,
docker-compose version 1.26.2, build unknown
docker-py version: 4.3.0
CPython version: 2.7.5
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
[root@test6 ~]#
[root@test6 ~]# docker version
Client: Docker Engine - CommunityVersion: 19.03.12API version: 1.40Go version: go1.13.10Git commit: 48a66213feBuilt: Mon Jun 22 15:46:54 2020OS/Arch: linux/amd64Experimental: falseServer: Docker Engine - CommunityEngine:Version: 19.03.12API version: 1.40 (minimum version 1.12)Go version: go1.13.10Git commit: 48a66213feBuilt: Mon Jun 22 15:45:28 2020OS/Arch: linux/amd64Experimental: falsecontainerd:Version: 1.2.13GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429runc:Version: 1.0.0-rc10GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dddocker-init:Version: 0.18.0GitCommit: fec3683
设置国内的源
> /etc/docker/daemon.json{"registry-mirrors" : ["https://mirror.ccs.tencentyun.com","http://registry.docker-cn.com","http://docker.mirrors.ustc.edu.cn","http://hub-mirror.c.163.com"],"insecure-registries" : ["registry.docker-cn.com","docker.mirrors.ustc.edu.cn"],"debug" : true,"experimental" : true
}