Docker Networking, Lifecycle and Orchestration
Default network path
Docker normally places containers on a private bridge such as docker0. Virtual Ethernet connects the container to the bridge; Linux routing and NAT provide outbound connectivity.
container → veth → docker0 bridge → NAT/routing → physical networkPublishing a port exposes a service through the host:
docker run -p 8080:80 nginxThe host receives connections on port 8080 and forwards them to port 80 in the container. This is different from mounting storage with -v.
Lifecycle
| Command | Meaning |
|---|---|
docker run | Create and start a new container |
docker start | Start an existing stopped container |
docker stop | Gracefully stop it |
docker kill | Forcefully stop it |
docker rm | Remove the container and writable state |
docker ps -a | Show running and stopped containers |
docker logs | Read container output |
docker exec | Run a command inside it |
Orchestration
Compose defines a multi-container application, commonly with YAML describing web, database, volumes and networks. Swarm and Kubernetes extend management across multiple hosts: placement, restart, scaling, service discovery and updates. See Container Orchestration and Kubernetes in Lecture 10 - Microservices and Containers Orchestration for how dedicated orchestrators handle microservices at scale.
Retrieval
What does -p 8080:80 do? It publishes host port 8080 to container port 80. It does not preserve files.
Source: Lecture 07 - Lightweight Virtualization - LXC and Docker, PDF pages 38-40, 48-55 and 70-72.