컨테이너 혁명, 개발을 바꾸다

 

🔍 Docker 개념 요약

Docker는 애플리케이션을 컨테이너라는 단위로 패키징, 배포, 실행할 수 있게 해주는 오픈소스 플랫폼입니다.

컨테이너는 "가벼운 가상 머신"처럼 동작하며, 코드와 그 실행 환경(라이브러리, 설정 등)을 하나로 묶어 이식성을 높여줍니다.

🔧 비유로 이해해보자:

개발 환경을 일일이 맞추는 게 번거롭다고요?
Docker는 마치 완성된 도시락처럼, “딱 그 상태로 어딜 가도 똑같이 먹을 수 있는” 앱을 만들어줍니다. 🍱

 

✅ Docker를 사용하는 이유

이유설명
이식성 (Portability) OS나 하드웨어에 상관없이 어디서든 동일하게 실행 가능
일관성 (Consistency) "내 컴에선 되는데?" 현상 방지
빠른 배포 (Rapid Deployment) 빌드 → 실행 → 종료까지 몇 초면 끝
경량화 (Lightweight) VM보다 훨씬 가벼움 (수 MB 수준도 가능)
마이크로서비스와 찰떡궁합 각각의 서비스들을 개별 컨테이너로 관리 가능

 

🛠 Docker 설치 방법 (Ubuntu 기준)

 

https://get.docker.com/ 

일단 요사이트를 참조하세요

 

# Usage
# ==============================================================================
#
# To install the latest stable versions of Docker CLI, Docker Engine, and their
# dependencies:
#
# 1. download the script
#
#   $ curl -fsSL https://get.docker.com -o install-docker.sh
#
# 2. verify the script's content
#
#   $ cat install-docker.sh
#
# 3. run the script with --dry-run to verify the steps it executes
#
#   $ sh install-docker.sh --dry-run
#
# 4. run the script either as root, or using sudo to perform the installation.
#
#   $ sudo sh install-docker.sh

요 부분 쉘에다 복사해다 붙이고 실행

# Command-line options
# ==============================================================================
#
# --version 
# Use the --version option to install a specific version, for example:
#
#   $ sudo sh install-docker.sh --version 23.0
#
# --channel <stable|test>
#
# Use the --channel option to install from an alternative installation channel.
# The following example installs the latest versions from the "test" channel,
# which includes pre-releases (alpha, beta, rc):
#
#   $ sudo sh install-docker.sh --channel test
#
# Alternatively, use the script at https://test.docker.com, which uses the test
# channel as default.
#
# --mirror <aliyun|azurechinacloud>
#
# Use the --mirror option to install from a mirror supported by this script.
# Available mirrors are "Aliyun" (https://mirrors.aliyun.com/docker-ce), and
# "AzureChinaCloud" (https://mirror.azure.cn/docker-ce), for example:
#
#   $ sudo sh install-docker.sh --mirror AzureChinaCloud</aliyun|azurechinacloud></stable|test>

그리고 다시 요부분도 실행

아래는 챗 지피티의 설명이에요

 

🔽 1. 기존 설치 제거 (이미 있는 경우)

sudo apt-get remove docker docker-engine docker.io containerd runc

 

⬇️ 2. 필수 패키지 설치

sudo apt-get update sudo apt-get install ca-certificates curl gnupg lsb-release
 

🔑 3. Docker 공식 GPG 키 추가

 
sudo mkdir -p /etc/apt/keyrings
 
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

 

📌 \ (역슬래시)의 의미

**리눅스/유닉스 셸에서는 역슬래시 \를 줄 끝에 붙이면, "이 줄과 다음 줄은 하나의 명령이다"**라고 알려주는 거야.

 

✅ 주의할 점

  • \ 뒤에 공백이 있으면 안 돼!
     
    echo \           ← 이런 식이면 안 됨 ❌
  • 다음 줄과 붙어 있는 것처럼 작동

 

📦 4. 리포지토리 추가

echo \
"deb [arch=$(dpkg --print-architecture) \
signed-by=/etc/apt/keyrings/docker.gpg] \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
 

 

📦 리눅스에서 리포지토리(Repository)란?

리포지토리는 **소프트웨어 패키지들이 저장되어 있는 서버(또는 저장소)**를 말해요.
리눅스에서 프로그램을 설치할 때 apt install 같은 명령을 쓰면, 이 명령은 결국 리포지토리에서 해당 소프트웨어를 다운로드해와서 설치하는 거예요.

 

⚙️ 5. Docker 설치

sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
 

✅ 6. 설치 확인

sudo docker --version

 

---> 저도 아래처럼 사용해보지는 못했어요 함께 알아가 봅시다 고마워요

🚀 Docker 기본 사용 예시

# Hello World
컨테이너 실행
sudo docker run hello-world
 
# 컨테이너 목록 보기
sudo docker ps -a
 
# 중지된 컨테이너 삭제
sudo docker rm [컨테이너ID]
 
# 이미지 삭제
sudo docker rmi [이미지ID]

 

🔒 비root 사용자로 실행하려면?

sudo usermod -aG docker $USER

그 후 로그아웃하고 다시 로그인하면 sudo 없이 docker 명령 사용 가능!

✍️ 마무리

Docker는 개발자, DevOps, 데이터 사이언티스트, 심지어 AI 모델 개발자에게도 없어선 안 될 도구입니다.
“한 번 만들면, 어디서든 똑같이 실행되는 환경”, 이게 바로 Docker의 매력이죠!

+ Recent posts