Logo

dev-resources.site

for different kinds of informations.

Why i use a smaller docker image

Published at
3/27/2023
Categories
dockerfile
docker
trivy
snyk
Author
igeadetokunbo
Categories
4 categories in total
dockerfile
open
docker
open
trivy
open
snyk
open
Author
13 person written this
igeadetokunbo
open
Why i use a smaller docker image

Image description

What is Docker? Docker is a famous platform for building, shipping, and running container applications. What are containers? Containers are a way to package software in a portable and isolated environment, this allows developers to package their application with all the dependencies it needs to run together, regardless of the host operating system.

Using Docker, developers can create container images containing everything needed to run an application, including the operating system, libraries, and runtime environment. These container images can be easily shared and deployed across different environments with docker software installed without requiring any modification.

There are cases whereby developers end up using big images which can be very harmful and contains vulnerabilities. Using containers makes things very easier, we can simply get an OS and install all the dependencies required.

There are several ways to ensure that the docker images developers are using are as small as possible. There is a big advantage, imagine running an application serving billions of users and the size is in kilobytes or megabytes.

The following are suggestions while writing a Dockerfile

  1. Implement docker layering and docker multi-build stage
  2. Use alpine or distroless or any other smaller OS as your base image or build your own OS
  3. Use .dockerignore which is similar to .gitignore you can use a .dockerignore file to exclude files and directories from being included in the Docker build context. This can significantly reduce the size of the build context and the resulting image.

In conclusion, in my next article, I will show an example of a Dockerfile in golang with the above suggestion. We will be able to compare the size of the docker image with and without optimizing the Dockerfile. We will also use tools like trivy or synk to check if there is a vulnerability or exploit in the docker image with or without optimization of the Dockerfile.

dockerfile Article's
30 articles in total
Favicon
Docker 101: A Guide to Docker Commands, Terminologies & Dockerfile
Favicon
Understanding Docker Compose File Format: Structure, Options, and Best Practices
Favicon
Mastering Dockerfile Syntax: A Complete Guide for Creating Custom Docker Images
Favicon
Understanding Docker Image Layers: Best Practices for Building Efficient Docker Images
Favicon
Best Practices for Writing Efficient and Maintainable Dockerfiles
Favicon
Dockerfile Explain
Favicon
Getting Started with Docker.
Favicon
Building and Deploying a Dockerized Web Application
Favicon
Dive Into Docker: A Hands-On Lab For Getting Started
Favicon
Dockerfile for PHP Laravel
Favicon
Container Files and Dockerfiles: A Comprehensive Guide
Favicon
Understanding Dockerfile: The Blueprint of Docker Containers and Images
Favicon
How to Create Docker Image for HTTPD service, including portfolio web site.
Favicon
Optimized Keycloak build
Favicon
Fun with Avatars: Containerize the app for deployment & distribution | Part. 2
Favicon
The Comprehensive Guide to Dockerfiles
Favicon
[Go Tour ] 2. Optimize Dockerfile
Favicon
Docker II: 5 tópicos para iniciar o mais rápido possível
Favicon
Mastering Dockerfile ️🐳: 10 Advanced Tips and Best Practices ⚔
Favicon
hadolint - Dockerfile linter
Favicon
Dockerfile
Favicon
Creating a GitHub Action for a Docker Image
Favicon
🐳 Boost Your Docker Workflow: Introducing Docker Init for Python Developers 🚀
Favicon
3 Tips to Improve Your Dockerfile Build Time
Favicon
Abrindo mares: Dockerfile, o que precisamos saber!
Favicon
Failed to Read Dockerfile
Favicon
Why i use a smaller docker image
Favicon
Differences Between a DockerFile, Docker Image, and Docker Container
Favicon
Clear up the confusions with Dockerfile instructions
Favicon
How to Create a Dockerfile?

Featured ones: