Updated: November 9, 2016
This should be a simple but useful tutorial. Recently, I showed you the fairly cool native implementation of orchestration with swarm mode in Docker 1.12, a brand new functionality that did not exist in earlier Docker builds. As it goes, CentOS 7 still has the older version in its repos, and if you want to test, you are seemingly stuck for now.
This will inevitably be resolved one day, but that should not discourage you from reading this article to its very end. After all, the 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
The first task will be to setup the Docker repo in CentOS. We've done this many times before, and 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.
Conclusion
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.
Cheers.