7 Tips to Optimize Your Docker Images

28/12/2020


7 Tips to Optimize Your Docker Images

#1 Design Container Images for a Single Job

By focusing a container image for single job it will be focused and lightweight. Making a container image multi-purpose will bloat the size

#2 Install Required Packages Only

Install the bare minimum packages for the single job the image will be used for

#3 Reduce Number of Layers

Each RUN command creates a new layer. Combining the layers can reduce the image size. So, smart combinations of commands can lead to smaller images.

#4 Avoid Storing Application data

Storing application data in the container will balloon up your images. For production environments, always use the volume feature to keep the container separate from the data

#5 Avoid Using :latest

Using specific tags can ensure that you know the exact image being used from the Docker registry and don’t have any surprises if the :latest changes

#6 Sort Multi-line Arguments

Whenever you have a multi-line argument, sort the arguments alphanumerically to improve maintenance of the code. Haphazard arguments can lead to duplications. They are also harder to update

#7 Use .dockerignore

Use the .dockerignore to exclude unnecessary files and folders that complicate the build process and bloat the image


Optimizing Docker Images

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Set up a MongoDB server with Docker

In this article, I am going to show you how to use Docker Compose to create a MongoDB container and access it using Mongo...
29/12/2020

Docker Container Links

Docker is an easy-to-use container technology for single applications. Regardless of expertise level, users can easily set...
28/12/2020

Install Redis From Docker Hub

Overview In this post, we will see how we can install and use Redis server from  Docker Hub. Using Docker Hub is very...
28/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Mua proxy v4 chạy socks5 để chơi game an toàn, tốc độ cao ở đâu?
18/05/2024

Thuê mua proxy Telegram trọn gói, tốc độ cao, giá siêu hời
18/05/2024

Thuê mua proxy Viettel ở đâu uy tín, chất lượng và giá tốt? 
14/05/2024

Dịch vụ thuê mua proxy US UK uy tín, chất lượng số #1
13/05/2024

Thuê mua proxy Việt Nam: Báo giá & các thông tin MỚI NHẤT
13/05/2024