Logo

dev-resources.site

for different kinds of informations.

Docker in development: Episode 4

Published at
1/9/2025
Categories
docker
webdev
agile
rails
Author
sinaptia_dev
Categories
4 categories in total
docker
open
webdev
open
agile
open
rails
open
Author
12 person written this
sinaptia_dev
open
Docker in development: Episode 4

The last episode was about how to perform everyday tasks in our containers. In this episode, we will see alternatives so we can optimize our images.

.dockerignore
The first tip to decrease the size of your image was already mentioned in the second episode of this series. Having a .dockerignore file will help you control what files you don’t want in your image, and therefore it will help you decrease the size of it.

Using smaller base images
This is obvious: using smaller base images produces smaller images. In the example we’ve been constructing, we use ruby:2.6, which is based on Debian stretch. The size of this image is 870MB, and depending on your app’s dependencies they can grow easily and double it. Fortunately, there are other lightweight alternatives such as ruby:2.6-alpine3.9, based on Alpine. The size of this image is only 50.9MB. Amazing!

Dive!
There’s an excellent tool called Dive that lets you inspect your image, and therefore a way to shrink it!

FROM:latest
FROM:latest is a linter/optimizer for your dockerfiles. Try it!

Minimize layers as much as you can
Instead of doing:

RUN apt-get update -qq
RUN apt-get install -y build-essential
RUN apt-get install -y curl
Do:

RUN apt-get update -qq && apt-get install -y build-essential curl
Each line in your dockerfile produces 1 layer. Each layer increases the image size a little. Try to combine layers as much as you can (without compromising readability) like in the example above.

Tips around package managers
If you’re using apt-get (instead of Alpine’s apk), you can add --no-install-recommends to your apt-get install command. The idea is that it will install necessary dependencies only (no recommended packages). You can also add rm -rf /var/lib/apt/lists/* after installing your apt-get dependencies. It’s even better if you do it in the same layer.

If you’re using apk, you should use --no-cache, to avoid storing the cache in your resulting image.

Try to keep up
In awesome-docker, you will find new tools, tips, and tricks.

Conclusion
You should try to shrink your image as much as you can. It will help you when you’re trying to deploy your dockerized app to production.

agile Article's
30 articles in total
Favicon
Agile Scrum Master Certification: Unlocking the Path to Effective Agile Leadership
Favicon
I am making an online kanban board
Favicon
Are Agile Misapplications Damaging Your Project Management?
Favicon
The Agile Trap: Why Sprinting Alone Won’t Get You to the Finish Line
Favicon
Docker in development: Episode 4
Favicon
The Lean Development Method: How Agile Practices Can Supercharge Your Startup's Growth
Favicon
The Mortal Enemy of Done is Perfect
Favicon
Anonymous Feedback in Retros: When, Why, and How
Favicon
A Quick Overview of Delivery Manager Role in the Modern Enterprise SDLC Process (Software Development Life Cycle)
Favicon
Plantilla d'iniciatives pel desenvolupament de software
Favicon
Top 5 Free Retrospective Tools for 2025
Favicon
Don't Waste Another Year: Get Agile Scrum Master Certification with H2K Infosys USA
Favicon
Top 7 Agile Project Management Certifications in 2025
Favicon
_Principais ações que você pode tomar para ter sucesso em uma nova área!
Favicon
đź’°CSM Certification Cost: Course, Exam, and Renewal Fees! Your Gateway to IT Growth
Favicon
How Often Are Sprint Reviews Conducted or Held?
Favicon
🚀 Unlocking Sprint Success with Jira Versions: A Strategic Guide
Favicon
Definition of Done, Definition of Ready and Acceptance Criteria are not the same darn thing
Favicon
Adapting to SAFe 6.0 in 2025: Overcoming Challenges and Advancing Your Career in the Tech World
Favicon
Launching AI Prototyping Projects
Favicon
The Great Debate: Agile vs. Waterfall Methodologies in Software Development🤔⚖️
Favicon
From Concept to Launch: 9 Product Management Frameworks for Creating Winning Products
Favicon
Agile Scrum Master Certification: Interview Questions for Beginners to Advanced Level
Favicon
Behavior Driven Development (BDD)
Favicon
The Complete Beginner Guide in IT Management Career Tracks : Scrum Masters & Project Managers
Favicon
How Scrum Empowers Teams to Take Ownership and Make Decisive Decisions
Favicon
Agile vs Waterfall Project Management: Choosing the right approach for your project
Favicon
Exclusive vSeeBox V3 Pro Sale – Transform Your Entertainment!
Favicon
Best Practices for Agile Development in Distributed Teams
Favicon
Why I Built scrum.host: A Free Tool for Planning Poker and Retrospectives

Featured ones: