Spunk Autos

Websites and web tools

Docker Tips: An Honest Review

Docker packages an application with its dependencies into an image that runs the same way on any machine with a container runtime. It is widely used, but it is not free of cost or complexity. This review weighs where Docker helps a small project, such as a shop's booking API, where it gets in the way, and how to use it well.

Where it helps

  • Consistent environments: the same image runs on a laptop, in CI and on the server, which removes most it works on my machine problems.
  • Easy local services: a database or cache for development starts with one command and is removed just as easily.
  • Clean deploys: you ship one tested image instead of installing packages on the server by hand.
  • Isolation between apps on the same host, each with its own dependencies.

Where it hurts

  • A plain static site does not need it. A static host is simpler.
  • Images can grow large and slow to build and pull without care.
  • File syncing between host and container can be slow on some desktop setups.
  • Containers add a layer to debug: networking, volumes and permissions all behave differently from a normal process.
  • Images need updating. A base image left alone for a year carries old vulnerabilities.

Tips that make a real difference

Order the Dockerfile for caching

Docker reuses cached layers until something changes. Copy the dependency manifest and install dependencies before copying the rest of the source code. Then a code change does not trigger a full reinstall.

Use multi-stage builds

Build in one stage with compilers and dev tools, then copy only the finished output into a small runtime image. The final image is smaller and contains fewer packages that could hold vulnerabilities.

Add a .dockerignore file

Exclude .git, node_modules, local environment files, logs and build output from the build context. It speeds up builds and keeps secrets out of images.

Pin versions

A latest tag changes under you. Pin base images to a specific version, and for strict reproducibility to a digest. Update deliberately and rebuild.

Do not run as root

Create a non-root user in the Dockerfile and switch to it with USER. If the application is compromised, the attacker has fewer privileges inside the container.

Keep secrets out of images

Anything copied or set with ENV during the build can be read from the image layers. Pass secrets at runtime through environment variables or a secrets manager, and use build-time secret mounts when a build step needs a token.

Verdict

Docker is worth learning for anyone who runs server-side code, and it pays off quickly for databases in local development. For a static brochure site it adds little. Used with a small image, pinned versions and a non-root user, it is a dependable part of a small team's toolkit; used carelessly, it hides problems inside large, outdated images.