The Secrets to Slash Docker Image Size by 10x

Before Optimization A typical Dockerfile for a Node.js application looks like this: 1 2 3 4 5 FROM node:18 WORKDIR /app COPY . . RUN npm install CMD ["npm", "start"] This image ends up being over 1GB in size. The main reasons for this are: Heavy base image Development tools included Presence of unnecessary files Accumulation of cache files Optimization Techniques 1. Implement Multi-Stage Builds Separate the build and runtime stages. ...

February 17, 2025 · 3 min · 555 words · In-Jun Hwang

From Docker Installation to Running the First Container

Preparing the Operating System Docker runs most reliably on a Linux operating system. This guide is intended for Ubuntu 20.04 LTS. Installing Docker Removing Existing Packages If you have a previous version of Docker installed on your system, remove it: 1 sudo apt-get remove docker docker-engine docker.io containerd runc Installing Prerequisites Install the packages required for Docker installation: 1 2 3 4 5 6 7 sudo apt-get update sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release Adding Docker’s Official GPG Key Add the GPG key to use Docker’s package repository: ...

February 17, 2025 · 3 min · 550 words · In-Jun Hwang

What is Docker: Core Concepts of Container Technology

The Genesis of Containers Deploying server applications has long been plagued by issues. Bug occurrence due to discrepancies between development and production environments, inconsistent server configurations, and complex dependency management were major culprits. Docker emerged to address these challenges. Docker Defined Docker is a container-based virtualization platform. It packages applications and everything required for their execution into standardized units known as containers. Containers vs. Virtual Machines Virtual Machines implement virtualization at the hardware level. Each virtual machine includes a full-fledged operating system. Containers, on the other hand, utilize operating system-level virtualization. They share the host operating system’s kernel and include only the necessary libraries and executables. ...

February 17, 2025 · 2 min · 370 words · In-Jun Hwang

Crafting a Dockerfile for your React Application

The Need for a Dockerfile Deploying your React applications as Docker containers offers the following advantages: Maintaining consistency between development and production environments Standardizing the build, test, and deployment process Enhancing scalability and flexibility Ease of environment variable management Basic Dockerfile Structure In its simplest form, a Dockerfile can be as follows: 1 2 3 4 5 6 7 8 FROM node:18 WORKDIR /app COPY package*.json ./ RUN npm install COPY . . RUN npm run build EXPOSE 3000 CMD ["npm", "start"] While this approach works, it is far from optimized, resulting in larger image sizes and longer build times. ...

February 17, 2025 · 2 min · 426 words · In-Jun Hwang

Understanding Docker Image Layers

Concept and Structure of Layers A Docker image is composed of multiple read-only layers. Each layer stores the filesystem changes introduced by a command in the Dockerfile. This is similar to commits in Git. It improves efficiency by storing only the changes. Docker mounts the layers as a single filesystem using a union file system. A writable container layer is added on top of the last layer. This can be visualized as multiple transparent sheets stacked on top of each other. ...

February 17, 2025 · 3 min · 531 words · In-Jun Hwang