DEV Community

Cover image for Docker Demystified

Docker Demystified

Frank Rosner on June 04, 2019

Introduction Since its open source launch in 2013, Docker became one of the most popular pieces of technology out there. A lot of compan...
Collapse
 
december1981 profile image
Stephen Brown

"Some applications have issues running inside a bridged network namespace if they do not distinguish properly between the network interface they bind to and the one they advertise. "

It's not clear to me what is meant here. Can you give an example or provide a link to something discussing this in more detail?

Collapse
 
frosnerd profile image
Frank Rosner • Edited

Sure!

When starting a server inside a container and having the virtual network bridge enabled, the IP address the server is binding on will not be visible from the other side of the bridge. So if this application advertises its binding IP address to other applications (happens mainly in distributed systems), they will not be able to reach it.

Thus, the applications need to support advertising a different IP address (the one visible from outside the container) than the binding IP address (the one inside the container). Does it make sense?

You can take a look at github.com/dask/distributed/issues... which describes such an issue.

Collapse
 
december1981 profile image
Stephen Brown

Thank you, a very clear response.

I recently had a problem the other way round (not quite symmetrical to this), where I needed to connect container services to a service listening on the host - postfix, so that I could send out mail from within a container. The docker recommended solution was to manually specify the netmask and gateway (representing the docker "host") of a bridged network to which the container services would belong. With this I would have a subnet of predictable IPs for the container services, allowing postfix to be configured to allow IP addresses in this network in its client restriction rules. (Postfix had originally been set to listen loopback only, and I had to make it listen on all interfaces, so that docker container services on this subnet could connect to it as something listening on the gateway interface... hence having to tighten security over connect able clients IPs)

Thread Thread
 
december1981 profile image
Stephen Brown

Then to add to confusion, there's docker swarm. I'm not even sure how networking works there under the hood. For instance, multiple instances of the same container shouldn't even expose their ports much less publish them, but HTTP proxy services like Traefik have a way of connecting with them through some kind of virtual port scheme? I have no idea...

Thread Thread
 
frosnerd profile image
Frank Rosner

Yeah some of the cluster managers have their own networking, like Kubernetes, e.g. Anyway if you only have one machine, no need to use a cluster manager.

In your case, couldn't you run postfix in another container if you need to access it and configure a user defined network so that the two containers can communicate?

Thread Thread
 
december1981 profile image
Stephen Brown

That is a better solution generally... indeed I considered it after I had set it up this way. It could be in a docker external "mail" network for the other containers, and also publish its port for services in the host proper. But I decided the mail server was so important (for stability, availability, etc) that I'd rather have it running as a plain service on the host.

Thread Thread
 
frosnerd profile image
Frank Rosner

Just being the devil's advocate here: Why is the availability and stability increased when it's running on the host, exactly?

Thread Thread
 
december1981 profile image
Stephen Brown

I guess it boils down to how stable the version of Docker is that you are running, or how adjusted it is with your host environment. If Docker falls over (and I have had this happen before), it will take all containers with it.

The reason for the Docker service going down may not be Docker's fault - whatever the case, you increase the number of factors that might make a critical service unavailable by deploying it inside a container, and I didn't want that with the mail server.

Thread Thread
 
frosnerd profile image
Frank Rosner

I agree. On the other hand if Docker goes down, nobody will be using postfix because all containers are down anyways... :P

Btw there is also the live-restore feature that enables you to keep containers running during a downtime of the daemon: docs.docker.com/config/containers/...

Thread Thread
 
december1981 profile image
Stephen Brown

I also had the intention of allowing the mail server to accept incoming mail at some point ... and the thought process was I'd rather never have mails bounce, as it's a real downer, especially with potential clients at stake, etc. Mind you, setting up a mail server properly to handle incoming mail is a pain, so I'll probably just delegate that to another mail service provider in the end.

Anyway, thanks for the live-restore feature - I hadn't heard of that until now!

Collapse
 
alejandrogorgues profile image
Alejandro Gorgues

Fantastic article, I have been working with docker and my plan is to make a tutorial explaining docker to my coworkers and future coworkers and you explained it so much better than me!!.👍

Collapse
 
mitchellclong profile image
Moe Long

This is an excellent write-up! I wish I'd had this to read when I first got started with Docker. Lots of "d'oh!" moments back during my Docker infancy. Great job taking a complex topic and making it digestible.

Collapse
 
frosnerd profile image
Frank Rosner

Thanks! It was the same for me when I started using Docker so I decided to dig into it. Additionally I was confronted with a lot of superficial knowledge by peers and customers who made bold claims but I did not have the knowledge to object.

Anyway I believe it's always very useful to understand how the things that you are using actually work.

Collapse
 
marcel_cremer profile image
Marcel Cremer

Hi Frank,

thank you for your great article. As you seem to have some real-world experience, with docker, maybe you also have some time to answer my Explain like I'm five: How does docker application update work - Question?

If not, no worries - I love your style of explaining things, so please keep up writing.

Cheers
Marcel

Collapse
 
frosnerd profile image
Frank Rosner

Done!

Collapse
 
djoleb profile image
Djordje Bajic

Thanks a lot! Great article!
🤘

Collapse
 
hassanfarid profile image
Hassan Farid

Execellent article. Loved reading and learning from it.

Collapse
 
robosek2 profile image
Robert Sęk

Thank you for this great blog post! It resolved some of doubts I had before :-)

Collapse
 
rhymes profile image
rhymes

Great intro, thank you!

Collapse
 
entrptaher profile image
Md Abu Taher

Fantastic demustification :D ...

Offtopic, What did you use to draw the images?

Collapse
 
frosnerd profile image
Frank Rosner
Collapse
 
devpablofeijo profile image
Pablo Ruan

Great article bro!!

Collapse
 
pabloc profile image
PabloC

Great article! tks!