Feb
06
2019

How to change the default Docker network in CentOS 6

One of the dev teams I used to support has been using Docker for jobs started on Jenkins executors(worker nodes).  The Jenkins worker nodes  have been around for a while  and consequently run CentOS 6 with older docker-io packages installed.

When I was asked to provision some new executors I was at a loss because there is very little documentation for installing docker in CentOS 6.  In fact it’s recommended by Docker not to use the older Linux kernels(2.6.x).

Goals of this post:

  • Install  docker-io on CentOS 6
  • configure daemon options – default network



Install Docker

At first I thought this would be easy… I google’d for a ‘how to’ on changing the default bridge IP Address in Docker.  The results pointed mostly to newer versions of Docker that use systemd and JSON configuration files.  The most common solution suggest adding an option to the ‘/etc/docker/daemon.json’.  The CentOS 6 docker-io package however is an earlier release of Docker and therefore we must use another method.

First thing is to install the ‘epel-release’ package for CentOS 6.  This includes many non-standard packages that I use frequently.

Now we can install the Docker IO package!



Start Docker Service

Notice that the default IP Address of bridge, ‘docker0’ is 172.17.42.1/255.255.0.0. In my unfortunate case our office internal LAN subnet is in the same address space. As soon as the bridge is active I get cut off from the Jenkins node because it is hosted at our datacenter(resulting in a routing loop). Luckily I was able to connect via a Xen console.


Configure docker-io default Network

Before we can edit the docker file and make a change, we must bring down the bridge0 and destroy it. If you don’t specifically remove this bridge interface docker will fail to start properly.


Now if you check, you should have no bridge interface.



Edit the Daemon Startup Options

Remember, these directions apply to CentOS 6 only! Consult documentation on Dockers website for newer releases. Navigate to ‘/etc/sysconfig’ folder.  This is the default place for system configuration files. Open the ‘docker’ file with your favorite text editor. Add, –bip=’192.168.34.1/24′ the ‘other_args’ variable.

Now start docker and check the interface after.

Finally we must test docker.

I also ran a Docker httpd container. You can see below it is answering HTTP request on the 192.168.34.4!

It is uncommon to run docker on older 2.6.x kernels. So it’s difficult to find good information. My hope is that I saved you some time if you have to support docker on legacy CentOS 6 hosts! Thank you for reading.

Written by mattb in: Linux | Tags: , , , , , , ,




No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment