Docker 1.9.0 and the new network configuration

Docker 1.9 is here and it introduces a new way to handle the networking between containers.
Because docker containers should live a short live before being replaced with their new versions one should ask himself do we really need the static IP that was existing until now and assigned to the Docker’s bridge? The usual IP you will see was 172.17.42.1.

After upgrading this IP will be gone. Instead other IPs will be created dynamically. Of course there will be another IP like 172.17.0.1 assigned to the docker0 bridge. You can use it if you are brave enough but better not.
However if you need a quick fix before going to bed you can use the Docker’s –bip parameter to set the bridge IP back to 172.17.42.1.

Another way is to go back to version 1.7.1 using your OS’s package manager or direct install/compile.
Later when you decide to start using Docker’s networking the right and better way, you can start from here.

How can you tell if a programmer knows Docker in 5 questions? | The Snap.hr Blog

Source: How can you tell if a programmer knows Docker in 5 questions? | The Snap.hr Blog

I struggled only on the last question about the difference between AUFS and DeviceMapper but these kind of questions always help me to find what I have to know to pass them. And I love to learn new things!

How to share a common IP between Docker containers

Sometimes you may build your images manually and don’t need something special but something to be used asap.

Such case happened when I wanted to tell php where is the mysql server. Usually after creating and removing containers you may see the mysql container’s ip changed and you have to change the configuration in your site again.

I’ve decided to use one approach that helps me set and forget about the sites’s configuration files and this is using a common IP inside my Docker host that is not 127.0.0.1 or 0.0.0.0.

I’ve made one ifconfig and I’ve seen these lines:

docker0 inet addr:172.17.42.1

lxcbr0 inet addr:10.0.3.1

I just used docker run …… -p 10.0.3.1:3306:3306 …/mysql

Then in the sites’s configs the mysql host was given as 10.0.3.1 instead of 127.0.0.1 or 172.17.0.X

That was since Docker version 0.9.0 went out. I now see only the docker0 ip which still solves the problem the same way with different common IP. I am using libcontainer’s API, no -e lxc, only custom docker data and temp directories set in the defaults file.

LXC 1.0 and Docker

Here’s a good article about the new features in LXC 1.0 and how Docker can benefit from them: http://www.vyomtech.com/2014/03/04/docker_and_linux_containers_lxc_1_0_release.html

I wonder how Docker will implement them if it’s decided. There are features already present in Docker like images and snapshots but the Go bindings in LXC will definitely make Docker lightning fast!