Docker
Docker
The de facto standard container platform. Packages applications as images and runs them as containers.
Docker
The de facto standard container platform. Packages applications as images and runs them as containers.
Docker is a platform for running applications in isolated environments called containers. By packaging code, runtime, libraries, and system tools into a single image, it solves the environment-difference problem of "it works on my computer...". Since its release in 2013, it has become synonymous with container technology.
Container technologies such as LXC (Linux Containers) existed before Docker, but Docker grew explosively by providing an easy-to-use CLI, an image layer system, and Docker Hub (an image registry). Today, almost all cloud services and CI/CD pipelines support Docker.
Docker uses the Linux kernel's cgroups (resource limits), namespaces (isolation), and Union File System (layered file system). Unlike virtual machines (VMs), it has no guest OS, so overhead is low, and image sizes are lightweight, starting from tens of MB. Dozens to hundreds of containers can run on the same host.
In practice, Docker is used for standardizing development environments, CI/CD pipelines, microservice deployment, isolating legacy apps, and more. Most container orchestration platforms, such as Kubernetes, ECS, and Cloud Run, use Docker images.
# Node.js 프로덕션 Dockerfile
# 멀티 스테이지 빌드로 이미지 크기 최소화
# 1단계: 빌드
FROM node:20-alpine AS builder
WORKDIR /app
# 의존성 먼저 설치 (캐시 활용)
COPY package*.json ./
RUN npm ci --only=production
# 소스 코드 복사 및 빌드
COPY . .
RUN npm run build
# 2단계: 실행
FROM node:20-alpine AS runner
WORKDIR /app
# 보안: non-root 사용자 사용
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 appuser
# 빌드 결과물만 복사
COPY --from=builder --chown=appuser:nodejs /app/dist ./dist
COPY --from=builder --chown=appuser:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=appuser:nodejs /app/package.json ./
USER appuser
# 환경 변수 설정
ENV NODE_ENV=production
ENV PORT=3000
EXPOSE 3000
# 헬스체크
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1
CMD ["node", "dist/server.js"]
"We keep running into development environment differences. How about standardizing with Docker? With docker-compose, we can bring up the DB and Redis locally all at once, and we can test in CI with the same environment."
"I have experience optimizing Docker images. I excluded build dependencies with multi-stage builds, used an Alpine base image, and improved the cache hit rate by optimizing layer order, which reduced the image size from 1.2GB to 180MB and cut build time from 5 minutes to 1 minute."
"The container was OOM Killed. I checked with docker stats, and the memory limit is 512MB, but actual usage kept increasing until it died. Let's check the application for memory leaks, and for now raise the limit to 1GB and redeploy."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
If you use latest as the image tag, you cannot trace which version was deployed and when. Be sure to use a version tag (v1.2.3) or a git commit SHA. It is best to generate tags automatically in CI.
By default, containers run as root. If there is a security vulnerability, the host can be affected as well. Specify a non-root user with the USER directive in the Dockerfile.
Exclude unnecessary files with .dockerignore, minimize images with multi-stage builds, monitor container status with HEALTHCHECK, and inject sensitive information via environment variables or secrets.