Skip to main content

buildah 기반의 컨테이너 생성

Buildah 명령어를 이용한 컨테이너 생성 절차.

Docker기반에서도 동일하게 컨테이너 생성 가능.

  1. buildah 패키지 설치
    $> yum install buildah -y
    

  2. 컨테이너 생성을 위한 Dockerfile 생성
    $> cat Dockerfile
    FROM docker.io/library/rockylinux
     
    RUN yum install tree httpd -y
    RUN mkdir -p /svc/http/
    COPY ./httpd.conf /svc/http/

  3. buildah로 컨테이너 생성
    $>  buildah bud -t tree:1.0
    STEP 1/4: FROM docker.io/library/rockylinux
    STEP 2/4: RUN yum install tree -y
    ...
    STEP 3/4: RUN mkdir -p /svc/http/
    STEP 4/4: COPY ./httpd.conf /svc/http/
    COMMIT tree:1.0
    Getting image source signatures
    Copying blob b9674b668e06 skipped: already exists
    Copying blob 16ea5ea65710 done
    Copying config 9bee15c469 done
    Writing manifest to image destination
    Storing signatures
    --> 9bee15c4692
    Successfully tagged localhost/tree:1.0
    9bee15c469245cb180c1e3a21eb220241e1940fefd4b8d9d28ec34ea6c8df3bb

  4. 컨테이너 생성 여부 확인
    $> podman  image ls
    REPOSITORY                    TAG         IMAGE ID      CREATED         SIZE
    docker.io/library/rockylinux  latest      c830f8e8f82b  2 weeks ago   211 MB
    localhost/tree                1.0         a77e50505d7a  32 seconds ago  257 MB

  5. 생성된 이미지 띄워서 dockerfile에 정의된 절차대로 작업 되었는지 확인
    $> podman run -dt localhost/tree:1.0
    c0b576f3bc807c98d1eb48c6f943c48cc43acae2c20b33d7851878ae6224c9cf
     
    $> podman  ps -a
    CONTAINER ID  IMAGE                                COMMAND      CREATED             STATUS            PORTS                                                                                                                                 NAMES
    c0b576f3bc80  localhost/tree:1.0                   /bin/bash    4 seconds ago       Up 4 seconds ago  dreamy_lamarr
     
    $> podman  exec -it dreamy_lamarr tree /svc/
    /svc/
    `-- http
        `-- httpd.conf
     
    1 directory, 1 file