Ubuntu Docker μ„€μΉ˜

  • kkumtree

2025-10-17T20:53:27+09:00

docker
ubuntu

Docker μ‚¬μš©μ„ μœ„ν•œ 기본적인 μ„€μΉ˜ 방법 λ©”λͺ¨

0. 이전 버전 제거 (선택)

  • μ§„ν–‰ 쀑인 Docker κ΄€λ ¨ μž‘μ—…μ΄ μ—†μ–΄, prune λͺ…λ Ήμ–΄λ₯Ό 톡해 κΈ°μ‘΄ Docker의 λ¦¬μ†ŒμŠ€λ“€μ„ μ‚­μ œ μ§„ν–‰ν•˜μ˜€μŠ΅λ‹ˆλ‹€.
docker system prune -a

docker system prune -a

  • 곡식 λ¬Έμ„œμ— 따라, μ•„λž˜ μ»€λ§¨λ“œλ‘œ μ‚­μ œλ₯Ό μ§„ν–‰ν•©λ‹ˆλ‹€. (겸사겸사 autoremove도 μ§„ν–‰ν•©λ‹ˆλ‹€.)
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
sudo apt-get autoremove
# ❯ for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
# [sudo] password for kkumtree: 
# Reading package lists... Done
# Building dependency tree... Done
# Reading state information... Done
# The following packages were automatically installed and are no longer required:
#   bridge-utils containerd pigz runc ubuntu-fan
# Use 'sudo apt autoremove' to remove them.
# The following packages will be REMOVED:
#   docker.io
# 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
# After this operation, 126 MB disk space will be freed.
# Do you want to continue? [Y/n] Y
# (Reading database ... 465886 files and directories currently installed.)
# Removing docker.io (27.5.1-0ubuntu3~24.04.2) ...
# '/usr/share/docker.io/contrib/nuke-graph-directory.sh' -> '/var/lib/docker/nuke-graph-directory.sh'
# Stopping 'docker.service', but its triggering units are still active:
# docker.socket
# Processing triggers for man-db (2.12.0-4build2) ...
# (...)
# Removing containerd (1.7.28-0ubuntu1~24.04.1) ...
# Processing triggers for man-db (2.12.0-4build2) ...
# Reading package lists... Done
# Building dependency tree... Done
# Reading state information... Done
# The following packages were automatically installed and are no longer required:
#   bridge-utils pigz ubuntu-fan
# Use 'sudo apt autoremove' to remove them.
# The following packages will be REMOVED:
#   runc
# 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
# After this operation, 34.3 MB disk space will be freed.
# Do you want to continue? [Y/n] Y
# (Reading database ... 465640 files and directories currently installed.)
# Removing runc (1.3.0-0ubuntu2~24.04.1) ...
# Processing triggers for man-db (2.12.0-4build2) ...
# ❯ sudo apt-get autoremove
# Reading package lists... Done
# Building dependency tree... Done
# Reading state information... Done
# The following packages will be REMOVED:
#   bridge-utils pigz ubuntu-fan
# 0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
# After this operation, 421 kB disk space will be freed.
# Do you want to continue? [Y/n] Y
# (Reading database ... 465612 files and directories currently installed.)
# Removing ubuntu-fan (0.12.16+24.04.1) ...
# ubuntu-fan: removing default /etc/network/fan configuration
# Removing bridge-utils (1.7.1-1ubuntu2) ...
# Removing pigz (2.8-1) ...
# Processing triggers for man-db (2.12.0-4build2) ...

1. Docker 곡식 GPG key와 APT λ ˆν¬μ§€ν† λ¦¬ μΆ”κ°€

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

alt text

2. Docker νŒ¨ν‚€μ§€λ₯Ό μ„€μΉ˜ν•©λ‹ˆλ‹€

(1) μ΅œμ‹  버전

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

(2) νŠΉμ • 버전

  • APT repositoryμ—μ„œ 받을 수 μžˆλŠ” 버전을 μ‘°νšŒν•©λ‹ˆλ‹€.
# List the available versions:
apt-cache madison docker-ce | awk '{ print $3 }'
# ❯ apt-cache madison docker-ce | awk '{ print $3 }'
# 5:28.5.1-1~ubuntu.24.04~noble
# 5:28.5.0-1~ubuntu.24.04~noble
# 5:28.4.0-1~ubuntu.24.04~noble
# 5:28.3.3-1~ubuntu.24.04~noble
# 5:28.3.2-1~ubuntu.24.04~noble
# 5:28.3.1-1~ubuntu.24.04~noble
# 5:28.3.0-1~ubuntu.24.04~noble
# (...)
  • 이후, μ›ν•˜λŠ” 버전을 ν™˜κ²½λ³€μˆ˜λ‘œ μ„€μ •ν•˜μ—¬ μ„€μΉ˜ν•©λ‹ˆλ‹€.
VERSION_STRING=5:28.5.1-1~ubuntu.24.04~noble
sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin

3. κΆŒν•œ μƒμŠΉ μ„€μ • (선택)

docker 그룹은 μ‚¬μš©μžμ—κ²Œ 루트 μˆ˜μ€€μ˜ κΆŒν•œμ„ λΆ€μ—¬ν•©λ‹ˆλ‹€. https://docs.docker.com/engine/security/#docker-daemon-attack-surface

sudo groupadd docker
sudo usermod -aG docker $USER
  • λ‘œκ·Έμ•„μ›ƒ, ν˜Ήμ€ μƒˆλ‘œμš΄ ν„°λ―Έλ„μ—μ„œ μ ‘μ†ν•©λ‹ˆλ‹€.
    ν˜Ήμ€ μ•„λž˜ μ»€λ§¨λ“œλ‘œ 그룹을 ν™œμ„±ν™”ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
newgrp docker

9. WARNING: Error loading config file (Troubleshooting)

# WARNING: Error loading config file: /home/user/.docker/config.json -
# stat /home/user/.docker/config.json: permission denied
  • 이 였λ₯˜λŠ” sudo λͺ…령을 이전에 μ‚¬μš©ν–ˆκΈ° λ•Œλ¬Έμ— ~/.docker/ 디렉터리에 λŒ€ν•œ κΆŒν•œ 섀정이 잘λͺ»λ˜μ—ˆμŒμ„ λ‚˜νƒ€λƒ…λ‹ˆλ‹€.
  1. ~/.docker/ 디렉터리λ₯Ό μ œκ±°ν•˜κ±°λ‚˜(μžλ™ μƒμ„±λ˜μ§€λ§Œ, μ‚¬μš©μž μ§€μ • 섀정은 μ‚­μ œλ©λ‹ˆλ‹€.)
  2. μ•„λž˜μ™€ 같이, μ†Œμœ κΆŒ 및 κΆŒν•œμ„ λ³€κ²½ν•©λ‹ˆλ‹€.
sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
sudo chmod g+rwx "$HOME/.docker" -R

Reference

kkumtree

plumber for infra

kkumtree

Source code on GitHub

Β© 2025 kkumtree and contributors All rights reserved.
Licensed under
CC BY-NC-ND 4.0