6.1.1.2 Creation Config Options
A focused guide to Creation Config Options, connecting core concepts with practical Docker and container operations.
Creation config options are the various flags and settings supplied at container creation time — environment variables, resource limits, restart policies, mounted volumes — that customize a container's behavior beyond whatever defaults the underlying image specifies.
Overriding Environment Variables
Environment variables baked into an image through ENV can be overridden at creation time, customizing the container's runtime configuration without modifying the image itself.
docker run -d -e LOG_LEVEL=debug -e PORT=8080 myapp:1.0
Setting Resource Limits
Memory and CPU limits constrain how much of the host's resources a given container is allowed to consume, preventing a single container from monopolizing shared resources.
docker run -d --memory=512m --cpus=1.5 myapp:1.0
Configuring a Restart Policy
A restart policy determines whether Docker automatically restarts a container if it stops unexpectedly, which is particularly important for production services expected to remain continuously available.
docker run -d --restart=unless-stopped myapp:1.0
Mounting Volumes at Creation Time
Persistent storage requirements are specified at creation time, determining where a container's data is actually stored.
docker run -d -v myapp-data:/var/lib/myapp/data myapp:1.0
Combining Multiple Configuration Options
Most real-world container creation combines several of these options together, fully specifying the container's intended runtime behavior in a single command.
docker run -d \
--name myapp \
--restart=unless-stopped \
--memory=1g \
-e NODE_ENV=production \
-v myapp-data:/data \
-p 8080:8080 \
myapp:1.0
Why Creation Config Options Matter
The configuration options specified at creation time determine much of a container's actual operational behavior — resource constraints, restart behavior, runtime environment — making careful attention to these options just as important as the underlying image itself for ensuring a container behaves correctly in production.