前言:這段時(shí)間都是在用Vagrant下Centos7學(xué)習(xí)Docker,安裝個(gè)docker-composer也是艱辛不斷。。
Dokcer-compose
先簡(jiǎn)單介紹下,docker-compose是一種Docker官方編排工具,負(fù)責(zé)實(shí)現(xiàn)對(duì)Docker容器集群的快速編排。
定位:定義和運(yùn)行多個(gè)Docker容器的應(yīng)用。
我為什么要使用它,主要是因?yàn)樗軌蚋旖莸木幣盼业娜萜?,且使用yml啟動(dòng)容器非常快捷。(暫時(shí)還沒深入到K8s,大佬勿噴。。)
進(jìn)入正題:
想安裝docker-compose那肯定要到官方文檔安裝靠譜啦!
地址:https://docs.docker.com/compose/install/

image.png
我在執(zhí)行第一條命令,就報(bào)錯(cuò):
curl: (35) Peer reports incompatible or unsupported protocol version.
說我Linux需要更新curl,果斷執(zhí)行更新命令:
yum update -y nss curl libcurl
無奈報(bào)錯(cuò),各種翻閱資料。。
報(bào)錯(cuò)如下:
yum update
Loaded plugins: fastestmirror
base | 3.6 kB 00:00:00
One of the configured repositories failed (Unknown),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=<repoid> ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable <repoid>
or
subscription-manager repos --disable=<repoid>
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again
研究發(fā)現(xiàn)重點(diǎn)是最后一行 for repository: epel/x86_64. 說明是這個(gè)倉儲(chǔ)出了問題。
解決辦法
把這個(gè)庫刪除
rm -f mv /etc/yum.repos.d/epel.repo
這樣執(zhí)行yum命令就可以正確的執(zhí)行。不過少了 epel 倉庫好多軟件包不能用。但是沒關(guān)系,對(duì)于現(xiàn)在的我沒有到那個(gè)需求。
而后再執(zhí)行
curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
總算能夠跑通。
最后感謝這個(gè)博主的分享解決我的問題
https://www.lampfree.com/linux/37.html