컨테이너 다운로드
1) 사전 준비
[root@localhost ~]# dnf install container-tools [root@localhost ~]# podman info --------------------------------------------------------------- registries: search: - registry.access.redhat.com - registry.redhat.io - docker.io - quay.io --------------------------------------------------------------- |
레지스트리 등록
2) conf 파일 설정
[root@localhost ~]# vi /etc/containers/registries.conf # registries.conf 파일을 수정한다. --------------------------------------------------------------- unqualified-search-registries = ["registry.access.redhat.com", "registry.redhat.io", "docker.io", "quay.io"] --------------------------------------------------------------- insecure = true --------------------------------------------------------------- |
# 일반 유저의 conf 파일 설정 [admin@localhost ~]$ mkdir -p /home/admin/containers/ # home/admin 밑에 컨테이너 디렉토리를 생성 [admin@localhost ~]$ sudo cp /etc/containers/registries.con/home/admin/containers/registries.conf # etc 폴더를 지나가기에 sudo 사용 [admin@localhost ~]$ vi ./containers/registries.conf # conf 파일 확인 --------------------------------------------------------------- unqualified-search-registries = ["registry.access.redhat.com", "registry.redhat.io", "docker.io", "quay.io"] --------------------------------------------------------------- insecure = true --------------------------------------------------------------- |
이미지 사용
3) 로그인 하기
[root@localhost ~]# podman login registry.access.redhat.com Username: # 레지스터리에 지정된 유저 Password: # 레지스터리에 지정된 패스워드 Login Succeeded! [root@localhost ~]# podman login registry.access.redhat.com --get-login {아무 이름} |
4) 컨테이너 이미지 확인
[admin@localhost ~]$ podman search python # python 이미지를 찾는다. NAME DESCRIPTION registry.access.redhat.com/ubi9/python-311 rhcc_registry.access.redhat.com_ubi9/python-... registry.redhat.io/ubi9/python-39 rhcc_registry.access.redhat.com_ubi9/python-... registry.redhat.io/rhscl/python-35-rhel7 Python 3.5 platform for building and running... docker.io/library/python Python is an interpreted, interactive, objec... [root@localhost ~]# skopeo inspect docker://registry.access.redhat.com/ubi9/python-311 # python-311의 대한 정보 확인 |
5) podman image 불러오기
[root@localhost ~]# podman pull registry.access.redhat.com/ubi9/python-311 # pull 명령어를 통해 이미지를 불러온다. Trying to pull registry.access.redhat.com/ubi9/python-311:latest... Getting image source signatures Checking if image destination supports signatures Copying blob 57014e322a9d done Copying blob dd7e340f5958 done Copying blob 51dd9c010a42 done Copying blob 33b9f09cff46 done Copying config d8eda7d6b1 done Writing manifest to image destination Storing signatures d8eda7d6b1eb214ff4097e19148ae87272046510041220e63a47ea4537ac9633 |
6) 불러온 image 정보 확인
[root@localhost ~]# podman images # image를 확인한다. REPOSITORY TAG IMAGE ID CREATED SIZE registry.access.redhat.com/ubi9/python-311 latest d8eda7d6b1eb 2 weeks ago 1.07 GB/ |
7) Containerfile을 사용하여 컨테이너 이미지 빌드
[root@localhost ~]# mkdir Container # 컨테이너 디렉토리를 만든다. [root@localhost ~]# cd Container [root@localhost Container]# vi Containerfile # 컨테이너 파일을 생성하여 아래 내용 추가 ---------------------------------------------------------- FROM registry.access.redhat.com/ubi8:latest RUN dnf install -y python36 CMD ["/bin/bash", "-c", "sleep infinity"] -------------------------------------------------------------- [root@localhost Container]# podman build -t python:1.0 . # 컨테이너 파일을 만든다. [root@localhost Container]# podman inspect localhost/python:1.0 # 빌드한 파일을 확인한다. [root@localhost Container]# podman ps # 실행 중인 컨테이너 확인 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES [root@localhost Container]# podman ps -a # 현재 존재하는 컨테이너 확인 (빌드만 했기에 컨테이너로써 존재하지 않기에 보이지 않는다. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES [root@localhost Container]# podman create --name python36 localhost/python:1.0 # python36이란 이름을 가지는 컨테이너를 생성한다. [root@localhost Container]# podman ps -a # 확인 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3344a34f9a12 registry.access.redhat.com/ubi8/python-38:latest sleep infinity 6 hours ago Created python36 |
8) 컨테이너 실행 및 확인
[root@localhost Container]# podman start python36 # 컨테이너 시작 python36 [root@localhost Container]# podman ps # 실행 중인 컨테이너 확인 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6806e40b1084 localhost/python:1.0 /bin/bash -c slee... About a minute ago Up 6 seconds python36 |
9) 컨테이너 제거
[root@localhost Container]# podman rm python36 # 컨테이너 삭제 Error: cannot remove container 6806e40b10844a05e8fec2d53bac3b43636ee94d7c6bdc4e3a06cd85579206cd as it is running - running or paused containers cannot be removed without force: container state improper # 작동 중인 컨테이너라서 삭제 불가 [root@localhost Container]# podman stop python36 # 컨테이너 중지 WARN[0010] StopSignal SIGTERM failed to stop container python36 in 10 seconds, resorting to SIGKILL python36 [root@localhost Container]# podman rm python36 # 삭제 python36 |
10) 생성된 이미지 제거
[root@localhost Container]# podman images # 이미지 확인 REPOSITORY TAG IMAGE ID CREATED SIZE localhost/python 1.0 f869ed9fce15 5 seconds ago 247 MB registry.access.redhat.com/ubi8/python-38 latest 91bcfba97b3c 2 weeks ago 901 MB registry.access.redhat.com/ubi9/python-311 latest d8eda7d6b1eb 2 weeks ago 1.07 GB registry.access.redhat.com/ubi8 latest 817f060b4672 5 weeks ago 215 MB [root@localhost Container]# podman rmi localhost/python:1.0 # 이미지 삭제 Untagged: localhost/python:1.0 Deleted: 318cfbc49637242660ae4021cc5dc1d29da924b1371c6cc3e5579d1ce6d90afd Deleted: 5a8b2cbed50a2b49362dc317e01df243a0a6cb571de17bca65f5e53724007a3b |
'리눅스-podman > 실습' 카테고리의 다른 글
podman 실습 - 컨테이너 유닛 생성 (0) | 2023.09.01 |
---|---|
podman 실습 - mariadb 생성 및 설정 (0) | 2023.09.01 |
podman (1) | 2023.09.01 |