docker run -d --name web -p 8080:80 nginxDetached, named, host port 8080 → container 80.
The docker CLI commands you actually need, plus Dockerfile instructions. For multi-container setups see the Docker Compose cheat sheet.
20 entries
docker run -d --name web -p 8080:80 nginxDetached, named, host port 8080 → container 80.
docker run --rm -it python:3.12 bashInteractive throwaway container.
docker run -e NODE_ENV=production --env-file .env appEnvironment variables.
docker run -v $(pwd):/app -w /app node:22 npm testBind-mount the current folder.
docker ps
docker ps -aRunning / all containers.
docker logs -f webFollow logs.
docker exec -it web shShell inside a running container.
docker stop web
docker start web
docker rm webStop, start, remove.
docker inspect web
docker statsDetails; live resource usage.
docker build -t myapp:1.0 .Build from the Dockerfile in this folder.
docker images
docker rmi myapp:1.0List / remove images.
docker tag myapp:1.0 ghcr.io/me/myapp:1.0
docker push ghcr.io/me/myapp:1.0Tag and push to a registry.
docker pull postgres:16Download an image.
docker volume create pgdata
docker run -v pgdata:/var/lib/postgresql/data postgres:16Named volume survives container removal.
docker network create appnet
docker run --network appnet --name db postgres:16Containers on one network reach each other by name.
docker system dfDisk used by images, containers, volumes.
docker system pruneRemove stopped containers, unused networks, dangling images.
docker image prune -aRemove all unused images.
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
USER 1000
EXPOSE 8000
CMD ["gunicorn", "-b", "0.0.0.0:8000", "app:app"]Copy dependency files first so the install layer is cached.
FROM node:22 AS build
WORKDIR /app
COPY . .
RUN npm ci && npm run build
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/htmlMulti-stage build keeps the final image small.
An image is a read-only template (layers of files plus metadata). A container is a running (or stopped) instance of an image with its own writable layer.
ENTRYPOINT sets the executable that always runs; CMD supplies default arguments that docker run can override. Use exec form (JSON array) for both so signals reach your process.
Check with docker system df, then run docker system prune. Add -a to also remove unused images and --volumes to remove unused volumes (careful: that deletes data).