Images
Download and list
Section titled “Download and list”docker pull nginx:1.27 # download an imagedocker images # list local imagesdocker image inspect nginx:1.27 # full metadata (JSON)docker image history nginx:1.27 # layers and their sizesBuild your own
Section titled “Build your own”A minimal Dockerfile (Podman also reads it as Containerfile):
FROM python:3.13-slimWORKDIR /appCOPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txtCOPY . .EXPOSE 8000CMD ["python", "app.py"]docker build -t myapp:1.0 . # build from the Dockerfile in the current directorydocker build -t myapp:1.0 -f other.Dockerfile .The . at the end is the build context: the folder whose files COPY can see. Add a .dockerignore (same syntax as .gitignore) to keep node_modules, .git or secrets out of it.
Tips for smaller, faster builds:
- Copy the dependency files and install them before copying the rest of the code, so that layer is cached while you only change code.
- Use
-slimor-alpinebase images. - Combine related
RUNsteps and clean caches in the same step.
Tag and push
Section titled “Tag and push”docker tag myapp:1.0 ghcr.io/myuser/myapp:1.0docker login ghcr.iodocker push ghcr.io/myuser/myapp:1.0Remove
Section titled “Remove”docker rmi myapp:1.0 # remove an image (fails if a container still uses it)docker image prune # remove dangling images (untagged leftovers of old builds)docker image prune -a # remove every image not used by any container