웹사이트 검색

Ubuntu 22.04에 Podman을 설치하는 방법


이 튜토리얼은 다음 OS 버전에 대해 존재합니다.

  • Ubuntu 22.04(Jammy Jellyfish)
  • Ubuntu 20.04(Focal Fossa)

이 페이지에서

  1. 전제 조건
  2. Ubuntu 22.04에 Podman 설치
  3. Podman 레지스트리 구성
  4. Podman으로 이미지 다운로드
  5. Podman을 사용하여 컨테이너 생성 및 관리\n
  6. Podman 시작하기\n
  7. 결론

"Pod Manager"라고도 하는 Podman은 컨테이너를 만들고 관리하는 데 사용되는 오픈 소스 도구입니다. Docker 데몬에 의존하지 않고 Docker와 호환되는 libpod 라이브러리의 일부입니다. Kubernetes를 위한 단순하고 가벼운 컨테이너 런타임 환경입니다. Docker 라이센스의 최근 변경으로 podman은 대부분의 Linux 시스템에서 사용할 수 있는 좋은 대안이 될 수 있습니다.

이 튜토리얼에서는 Ubuntu 22.04 서버에 Podman을 설치하고 사용하는 방법을 보여줍니다.

전제 조건

  • Ubuntu 22.04를 실행하는 서버.\n
  • 루트 암호는 서버에서 구성됩니다.\n

Ubuntu 22.04에 Podman 설치

기본적으로 Podman 패키지는 Ubuntu 기본 리포지토리에 포함되어 있습니다. 다음 명령을 실행하여 설치할 수 있습니다.

apt install podman -y

Podman이 설치되면 다음 명령으로 확인할 수 있습니다.

podman -v

다음 출력에 Podman 버전이 표시되어야 합니다.

podman version 3.4.4

다음 명령을 사용하여 Podman에 대한 자세한 정보를 볼 수도 있습니다.

podman info

다음 출력이 표시되어야 합니다.

host:
  arch: amd64
  buildahVersion: 1.23.1
  cgroupControllers:
  - cpuset
  - cpu
  - io
  - memory
  - hugetlb
  - pids
  - rdma
  - misc
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: 'conmon: /usr/bin/conmon'
    path: /usr/bin/conmon
    version: 'conmon version 2.0.25, commit: unknown'
  cpus: 2
  distribution:
    codename: jammy
    distribution: ubuntu
    version: "22.04"
  eventLogger: journald
  hostname: ubuntu2204
  idMappings:

Podman 레지스트리 구성

기본적으로 Podman 레지스트리는 웹에서 컨테이너 이미지를 다운로드하고 설치하도록 구성되어 있지 않습니다. 따라서 먼저 구성해야 합니다.

nano /etc/containers/registries.conf

다음 줄을 추가합니다.

[registries.search]
registries=["registry.access.redhat.com", "registry.fedoraproject.org", "docker.io"]

완료되면 파일을 저장하고 닫습니다.

Podman으로 이미지 다운로드

Podman을 사용하면 웹에서 이미지를 쉽게 검색하고 다운로드할 수 있습니다. 예를 들어 Debian 이미지를 검색하려면 다음 명령을 실행합니다.

podman search debian

다음 출력에서 모든 Debian 이미지 목록을 가져와야 합니다.

INDEX       NAME                                           DESCRIPTION                                      STARS       OFFICIAL    AUTOMATED
docker.io   docker.io/library/ubuntu                       Ubuntu is a Debian-based Linux operating sys...  14959       [OK]        
docker.io   docker.io/library/debian                       Debian is a Linux distribution that's compos...  4435        [OK]        
docker.io   docker.io/library/neurodebian                  NeuroDebian provides neuroscience research s...  93          [OK]        
docker.io   docker.io/bitnami/debian-base-buildpack        Debian base compilation image                    2                       [OK]
docker.io   docker.io/mirantis/debian-build-ubuntu-xenial                                                   0                       
docker.io   docker.io/mirantis/debian-build-ubuntu-trusty                                                   0                       
docker.io   docker.io/osrf/debian_arm64                    Debian arm64 Base Images                         1                       
docker.io   docker.io/rancher/debianconsole                                                                 1                       
docker.io   docker.io/dokken/debian-10                     Debian 10 image for use with kitchen-dokken      0                       
docker.io   docker.io/dokken/debian-9                      Debian 9 image for kitchen-dokken                0                       
docker.io   docker.io/ustclug/debian                       Official Debian Image with USTC Mirror           1                       
docker.io   docker.io/dokken/debian-8                      EOL: Debian 8 image for kitchen-dokken           0                       
docker.io   docker.io/dokken/debian-11                     Debian 11 image for use with kitchen-dokken      0                       
docker.io   docker.io/corpusops/debian-bare                https://github.com/corpusops/docker-images/      0                       
docker.io   docker.io/datadog/debian-i386                                                                   0                       
docker.io   docker.io/corpusops/debian                     debian corpusops baseimage                       0                       
docker.io   docker.io/osrf/debian_armhf                    Debian Armhf Base Images                         1                       
docker.io   docker.io/treehouses/debian                                                                     2                       
docker.io   docker.io/dokken/debian-7                      EOL DISTRO: For use with kitchen-dokken, Bas...  0                       
docker.io   docker.io/treehouses/debian-tags                                                                0                       
docker.io   docker.io/dokken/debian-12                                                                      0                       
docker.io   docker.io/dockage/debian-runit                 Docker image uses runit as a process supervi...  2                       [OK]
docker.io   docker.io/galaxy/debian32-wheel                                                                 0                       
docker.io   docker.io/galaxy/debian-wheel                                                                   0                       
docker.io   docker.io/dockage/debian                       Debian image that forms the base for some Do...  2                       [OK]

그런 다음 다음 명령을 사용하여 인터넷에서 최신 Debian 이미지를 다운로드합니다.

podman pull debian

아래와 같이 최신 데비안 이미지를 검색하고 다운로드합니다.

Getting image source signatures
Copying blob 23858da423a6 done  
Copying config 43d28810c1 done  
Writing manifest to image destination
Storing signatures
43d28810c1b4c28a1be3bac8e0e40fcc472b2bfcfcda952544ed99cb874d2b1a

이제 다음 명령을 사용하여 다운로드한 이미지를 확인할 수 있습니다.

podman images

다음 출력이 표시되어야 합니다.

REPOSITORY                TAG         IMAGE ID      CREATED     SIZE
docker.io/library/debian  latest      43d28810c1b4  5 days ago  129 MB

Podman을 사용하여 컨테이너 생성 및 관리

Podman을 사용하면 명령줄을 통해 컨테이너를 쉽게 생성하고 관리할 수 있습니다.

Debian 이미지에서 컨테이너를 만들려면 다음 명령을 실행합니다.

podman run -dit --name debian-container debian

컨테이너가 생성되면 다음 명령으로 실행 중인 컨테이너를 볼 수 있습니다.

podman ps

다음 출력이 표시되어야 합니다.

CONTAINER ID  IMAGE                            COMMAND     CREATED        STATUS            PORTS       NAMES
533698eaf6f1  docker.io/library/debian:latest  bash        6 seconds ago  Up 6 seconds ago              debian-container

Debian 컨테이너에 연결하려면 다음 명령을 실행합니다.

podman attach debian-container

아래와 같이 Debian 컨테이너로 이동합니다.

:/# 

다음 명령을 사용하여 컨테이너 버전을 확인할 수 있습니다.

cat /etc/os-release

다음과 같은 결과가 표시됩니다.

PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

컨테이너를 종료하려면 다음 명령을 실행합니다.

:/# exit

컨테이너를 중지하려면 다음 명령을 실행합니다.

podman stop debian-container

컨테이너를 시작하려면 다음 명령을 실행합니다.

podman start debian-container

컨테이너를 삭제하려면 다음 명령을 실행합니다.

podman rm debian-container

Debian 이미지를 삭제하려면 다음 명령을 실행합니다.

podman rmi debian

다음과 같은 결과가 표시됩니다.

Untagged: docker.io/library/debian:latest
Deleted: 43d28810c1b4c28a1be3bac8e0e40fcc472b2bfcfcda952544ed99cb874d2b1a

다음 명령을 사용하여 모든 Podman 명령 옵션을 나열할 수 있습니다.

podman --help

다음 출력에서 모든 유용한 옵션을 볼 수 있습니다.

Manage pods, containers and images

Usage:
  podman [options] [command]

Available Commands:
  attach      Attach to a running container
  auto-update Auto update containers according to their auto-update policy
  build       Build an image using instructions from Containerfiles
  commit      Create new image based on the changed container
  container   Manage containers
  cp          Copy files/folders between a container and the local filesystem
  create      Create but do not start a container
  diff        Display the changes to the object's file system
  events      Show podman events
  exec        Run a process in a running container
  export      Export container's filesystem contents as a tar archive
  generate    Generate structured data based on containers, pods or volumes
  healthcheck Manage health checks on containers
  help        Help about any command
  history     Show history of a specified image
  image       Manage images
  images      List images in local storage
  import      Import a tarball to create a filesystem image
  info        Display podman system information
  init        Initialize one or more containers
  inspect     Display the configuration of object denoted by ID
  kill        Kill one or more running containers with a specific signal
  load        Load image(s) from a tar archive
  login       Login to a container registry
  logout      Logout of a container registry
  logs        Fetch the logs of one or more containers
  machine     Manage a virtual machine
  manifest    Manipulate manifest lists and image indexes
  mount       Mount a working container's root filesystem
  network     Manage networks
  pause       Pause all the processes in one or more containers
  play        Play containers, pods or volumes from a structured file
  pod         Manage pods
  port        List port mappings or a specific mapping for the container
  ps          List containers
  pull        Pull an image from a registry
  push        Push an image to a specified destination
  rename      Rename an existing container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Removes one or more images from local storage
  run         Run a command in a new container
  save        Save image(s) to an archive
  search      Search registry for image
  secret      Manage secrets
  start       Start one or more containers
  stats       Display a live stream of container resource usage statistics
  stop        Stop one or more containers
  system      Manage podman
  tag         Add an additional name to a local image
  top         Display the running processes of a container
  unmount     Unmounts working container's root filesystem
  unpause     Unpause the processes in one or more containers
  unshare     Run a command in a modified user namespace
  untag       Remove a name from a local image
  version     Display the Podman version information
  volume      Manage volumes
  wait        Block on one or more containers

포드맨 시작하기

Podman을 사용하여 이미지, 볼륨 및 컨테이너를 생성하는 방법에 대한 자세한 가이드는 여기에서 확인할 수 있습니다. Podman 시작하기: 이미지, 컨테이너 및 볼륨 관리

결론

축하합니다! Ubuntu 22.04 서버에 Podman을 성공적으로 설치했습니다. 이제 Podman을 Docker의 대체 도구로 사용하여 컨테이너를 관리할 수 있습니다. 궁금한 점이 있으면 언제든지 문의해 주세요. Podman에 대한 자세한 내용은 Podman 문서 페이지를 참조하세요.