Loading Depth Study
Preparing your workspace
Docker separates container networking, runtime configuration, and persistent storage from the application image itself.
A container can listen on an internal port, while Docker can publish that port to the host. Environment variables allow runtime configuration such as database URLs or application modes without rebuilding the image. Volumes provide persistent storage that survives container replacement and are commonly used for databases or application data that should outlive a container.
A PostgreSQL container can store its database files in a Docker volume while the application container receives the database connection information through environment variables.
docker run -d \ --name postgres \ -e POSTGRES_PASSWORD=example \ -p 5432:5432 \ -v pgdata:/var/lib/postgresql/data \ postgres
A PostgreSQL container starts with a published port, runtime configuration, and persistent storage volume.