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 network

Publishing a port exposes a service through the host:

docker run -p 8080:80 nginx

The host receives connections on port 8080 and forwards them to port 80 in the container. This is different from mounting storage with -v.

Lifecycle

CommandMeaning
docker runCreate and start a new container
docker startStart an existing stopped container
docker stopGracefully stop it
docker killForcefully stop it
docker rmRemove the container and writable state
docker ps -aShow running and stopped containers
docker logsRead container output
docker execRun 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.