Introduction to Docker Networking

This lesson is an overview of networking in Docker.

It’s always the network!

Any time we experience infrastructure issues, we always blame the network. One reason is that networks are at the center of everything. With this in mind, it’s important you have a strong understanding of Docker networking.

Networking was difficult in the early days of Docker. Fortunately, it’s almost a pleasure these days.

This chapter will get you up to speed with the fundamentals of Docker networking. You’ll learn all the theory behind the Container Network Model (CNM) and libnetwork, and you’ll get your hands dirty with lots of examples. You’ll learn about overlay networks in the next chapter.

Prerequisites and environment setup

A few quick things before we start.

Everything we’ll cover relates to Linux containers. We recommend you follow along using something like Multipass or Play with Docker, as they give you easy access to some of the Linux commands we’ll use. We don’t recommend following along on Docker Desktop, as it runs everything inside a Linux VM, and you won’t have access to the Linux commands.

Some of the examples explain how networking works on a swarm. You’ll only be able to follow these if you’re following along with a Swarm cluster.

The TLDR

Docker runs microservices applications comprised of many containers that work together to form the overall app. These containers need to be able to communicate, and some will have to connect with external services, such as physical servers, virtual machines, or something else.

Get hands-on with 1300+ tech skills courses.