Docker Networking and Communication Overview
This content delves into Docker networking and communication concepts, covering topics such as virtual network devices, container access to external networks, traffic handling, network drivers, network configurations, and Docker network types like none, host, and bridge. It also explores complex network namespace setups, Docker Compose for multi-container applications, and the setup of network communication between containers.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Docker Networking and Communication Marion Sudvarg, Chris Gill CSE 522S Advanced Operating Systems Washington University in St. Louis St. Louis, MO 63130 1
Last Time We provided a brief overview of networking Discussed virtual network devices: veth: emulates an ethernet port bridge: emulates a switch Discussed how containers can access outside networks via NAT, routing, and iptables Discussed how external traffic can reach containers: Port forwarding Macvlan bridging Docker helps to automate the setup for complex container networking scenarios CSE 522S Advanced Operating Systems 2
Today Docker networking: Framework for complex network namespace setup Docker compose: Allows specification and setup of multi- container applications Establishes the network communication between them CSE 522S Advanced Operating Systems 3
Docker Network Drivers none The container has no networking capabilities host The container is not placed in a new network namespace bridge The default network driver; the container is attached to a bridge CSE 522S Advanced Operating Systems 4
Network none Docker creates container in a new network namespace container1 lo Local loopback is enabled No other network interfaces are supplied lo eth0 Run with --network=none 192.168.1.12/24 docker run -it --rm --network=none alpine:latest CSE 522S Advanced Operating Systems 5
Network host Docker creates container in the host s network namespace (i.e., it does not create a new network namespace) container1 Processes in container have same access to network resources as those outside Run with --network=host lo eth0 Still in new UTS namespace unless --uts=host specified 192.168.1.12/24 docker run -it --rm --network=host alpine:latest CSE 522S Advanced Operating Systems 6
Network bridge Default network type container1 lo Docker sets up NAT with bridge as a gateway 10.1.1.2/24 veth1 docker0 10.1.1.10/24 bridge 10.1.1.1/24 This enables the container to access the outside network lo eth0 192.168.1.12/24 CSE 522S Advanced Operating Systems 7
Network Namespace Inspection Unlike with ip netns, Docker does not create bind mounts for the network namespaces This forces the namespace to disappear when all of its processes terminate You can inspect namespace membership with: docker exec ti <container> sh ls l /proc/self/ns/net CSE 522S Advanced Operating Systems 8
Listing Networks See the Docker networks with docker network list Notice there can be multiple bridge networks The default is named bridge CSE 522S Advanced Operating Systems 9
Network Inspection Inspect a network with docker network inspect <name> Lots of JSON-formatted information Network subnet and gateway Addresses of individual containers on the bridge CSE 522S Advanced Operating Systems 10
Port Forwarding Allows external socket requests to be forwarded to a container The requested port and container port can be different Example: container1 is a web server that listens on port 80 The host forwards requests on port 8080 to the container s port 80 docker run p 8080:80 apache:latest A client on the network sends a request on 8080 The request is received by a docker- proxy process Forwarded to the container port 80 container1 lo 10.1.1.2/24 veth1 docker0 10.1.1.10/24 bridge 10.1.1.1/24 Port 80 lo docker-proxy eth0 http://192.168.1.12:8080 192.168.1.12/24 CSE 522S Advanced Operating Systems 11
Docker Compose Automates the creation of applications with multiple containers Can be used to establish multiple bridge networks, and define the connections among them Allow a container to accept connections on ports from within its network Establish port forwarding from outside the network c11 c21 c12 route iptables br0 br1 c13 c22 Forward 80 Forward 8080->80 lo eth0 192.168.1.12/24 CSE 522S Advanced Operating Systems 12
Reading Assignments Several more pages from the Docker docs website: The Networking overview page The Use bridge networks page The Network settings section of the Docker run reference The Overview of Docker Compose page The Install Docker Compose page The Getting Started with Docker Compose page Again, it s fine to mostly skim these (Optional) DKR book: Chapter 7: Information on debugging container-related issues Pages 167-177: An example of using Docker Compose Chapter 11: How Docker works under the hood. Now that you ve experienced Docker, and you understand the underlying kernel mechanisms, this chapter will tie all of these concepts together. CSE 522S Advanced Operating Systems 13
Studio Exercises Today Create a simple web application! Connect it to the network Create a separate container to monitor the web server Use Docker Compose to automate the configuration and communication of the two containers CSE 522S Advanced Operating Systems 14
Final Thoughts This wraps up our coverage of Docker this was not intended to be exhaustive! Docker is becoming increasingly popular in cloud and SMB infrastructure If you intend to work with Docker in your career, and want to learn more, look at: The DKR textbook The Docker Documentation: https://docs.docker.com/ Kubernetes (orchestrating containers across a cluster): https://kubernetes.io/docs/home/ Understanding the kernel mechanisms that support this technology is key to becoming an expert CSE 522S Advanced Operating Systems 15
Have a relaxing Spring Break! CSE 522S Advanced Operating Systems 16