Computer >> Hướng Dẫn Máy Tính >  >> Phần Mềm >> Máy Ảo

Cài đặt Docker 1.12+ trên CentOS 7: Hướng dẫn từng bước phiên bản mới nhất

Đây nên là một tutorial simple but useful. Gần đây, tôi chỉ cho bạn native implementation khá cool của orchestration với swarm mode trong Docker 1.12, một brand new functionality không tồn tại trong earlier Docker builds. Như nó diễn ra, CentOS 7 vẫn có older version trong repos, và nếu bạn muốn test, bạn seemingly stuck for now.

Điều này inevitably sẽ được resolved one day, but that should not discourage you from reading this article to its very end. After all, CentOS repos will always lag behind the official release, so if you do not want to compromise and bring the latest and greatest to your operating system, then this howto should help you get there. After me.

Setup Repository

First task sẽ là setup Docker repo trong CentOS. Chúng ta đã làm này many times before, và Docker is no exception in that sense. The necessary repo information is available on the Docker project site. Copy the following text into a docker.repo file and place it under /etc/yum.repos.d:

[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg

The next step is to install the new Docker packages, most importantly the new engine:

yum install docker-engine

But you will get an RPM conflict issue (or several):

Error: docker-engine-selinux conflicts with docker-selinux-1.10.3-46.el7.centos.10.x86_64
Error: docker-engine conflicts with docker-1.10.3-46.el7.centos.10.x86_64
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest

Transaction check error:
file /usr/bin/docker from install of docker-engine-1.12.1-1.el7.centos.x86_64 conflicts with file from package docker-common-1.10.3-46.el7.centos.10.x86_64

Resolve Package Errors

What you need to do is remove the existing Docker packages, including docker engine, selinux, common, and then install the new ones. This is a manual procedure, but it will not take a long time.

yum remove docker

Then, install the new one:

yum install docker

If you hit errors, manually remove the remaining packages, e.g.

yum remove docker-common-1.10.3-46.el7.centos.10.x86_64

Once you complete the installation successfully, check the version:

docker -v
Docker version 1.12.1, build 23cf638

You should also be able to run docker service commands without errors.

Kết luận

The only way this tutorial could have been simpler was if I had sung it to you, in reverse, in Prussian. But there we are. One day, version 1.12 will be ancient past, but if you happen to be reading this article because you're running a slightly more conservative server edition of a Linux distro, and its repo data is slightly behind the official release channels, then you can use this guide to work around the problem and test the latest Docker stuff without compromising on the rest of the goodies a distro like CentOS provides you.

Anyhow, the methodology of enabling new repos is not new. We did this time and again when we tamed CentOS into submission and perfection. And resolving repository conflicts is something we encountered with openSUSE pimping in the past. Finally, we have Docker running, and all is well. Very simple. Elegant. Efficient. Enjoy, and stay tuned for more container stuff.

Chúc vui.