Docker Run Options
The flags that matter: detach, ports, env, volumes, limits.
- docker run
- docker env
- docker ports
- docker volumes
- resource limits
Docker Run Options
The flags that matter: detach, ports, env, volumes, limits.
Commands
| Command | What it does |
|---|---|
docker run -d --name api app:v1 | Detached with a stable name |
docker run -p 8080:80 -e PORT=80 app:v1 | Publish port and set env var |
docker run --env-file .env app:v1 | Load many env vars from a file |
docker run -v data:/data app:v1 | Persist /data in a named volume |
docker run --memory 512m --cpus 1 app:v1 | Cap memory and CPU |
docker run --rm -it ubuntu:24.04 bash | Throwaway interactive shell |
Example
docker run -d --name api --env-file .env -p 8080:8080 --memory 512m app:v1
docker ps --filter name=api
FAQ
-p host:container — which side is which?
Left is the host port you open, right is the container port the app listens on.
When should I use --rm?
For one-off commands (migrations, shells): the container self-deletes on exit, no clutter.
자주 묻는 질문
-p host:container — which side is which?
Left is the host port you open, right is the container port the app listens on.
When should I use --rm?
For one-off commands (migrations, shells): the container self-deletes on exit, no clutter.
Docker
Docker Install and Setup
Verify the Docker engine, configure context, and check versions.
Docker Images
Pull, list, tag, inspect, and remove images confidently.
Docker Containers
Run, list, stop, and clean up containers in daily work.
Docker Exec and Logs
Get a shell inside containers and read their logs effectively.