DataPandas

DataPandas

Share

Resources and Guides to Help You Transition into DevOps from a Non-Technical Background Your Journey Into DevOps and Data Science

Photos from DataPandas's post 20/04/2026

Your Docker image is bloated.

Cut image size and build time in 30 minutes:

Most teams ship containers packed with unused packages, stale caches, and hidden risks.

I did the same.

My early images took minutes to build and hundreds of MB to ship.
CI pipelines dragged.
Security scans flagged dozens of issues.

The fix was not new tools.

It was better Dockerfile habits.

Here’s what changed everything:

1) Combine apt-get update and install in one RUN layer.

- RUN apt-get update && apt-get install -y --no-install-recommends curl
- Remove /var/lib/apt/lists after install

This keeps layers clean and small.

2) Use --no-install-recommends.

You install only what you need.
No extra packages.
Smaller attack surface.

3) Pin base images by digest.

- FROM alpine:3.21@sha256:...

You get repeatable builds.
No surprise changes after rebuild.

4) Avoid cache traps.

- docker build --no-cache
- docker build --pull

Force fresh dependencies when needed.

5) Use multi-stage builds.

Build tools stay in one stage.
Production image copies only the final artifact.
No compilers in prod.

6) Set ENTRYPOINT and CMD with purpose.

ENTRYPOINT for the main process.
CMD for default arguments.
Clear behavior when someone runs docker run.

7) Create users with explicit UID and GID.

Avoid random ID shifts between builds.
Prevent permission issues in prod.

8) Clean up environment variables when you do not need them later.

ENV persists.
RUN export does not.

This prevents leaking data into runtime containers.

Start with one step today.

Open your Dockerfile.
Remove unused packages.
Add --no-install-recommends.
Clean the apt cache.

Rebuild.

Check the size difference.

If your image dropped by 100MB, how much faster will your pipeline run next week?

Small Dockerfile changes.
Faster builds.
Safer images.
Less pain in production.

Want your business to be the top-listed Computer & Electronics Service in Preston?
Click here to claim your Sponsored Listing.

Address


474 BROOK Street
Preston
PR23AJ