1 ã¯ããã«
ã¤ã¡ã¼ã¸ã®ä½æã¯ã以ä¸ã®æ¹æ³ãããã¾ãã
- Containerfileã使ãæ¹æ³
- Podmanã®commitã³ãã³ãã使ãæ¹æ³
ããã§ã¯ãContainerfileã使ç¨ããã¤ã¡ã¼ã¸ã®ä½ãæ¹ã«ã¤ãã¦èª¬æãã¾ããContainerfileã§ã¤ã¡ã¼ã¸ãä½æããéã«ã¯ãbuildã³ãã³ãã使ç¨ãã¾ããæ¸å¼ã¯ä»¥ä¸ã®éãã§ãã
$ podman build -t Podmanã¤ã¡ã¼ã¸å Containerfileæ ¼ç´ãã£ã¬ã¯ããª
åèæ
å ±ï¼Dockerfile リファレンス — Docker-docs-ja 24.0 ドキュメント
2 æ¤è¨¼ç°å¢
ãµã¼ãã®AlmaLinuxçæ°ã¯ä»¥ä¸ã®ã¨ããã§ãã
[root@server ~]# cat /etc/redhat-release
AlmaLinux release 9.2 (Turquoise Kodkod)
ã«ã¼ãã«çæ°ã¯ä»¥ä¸ã®ã¨ããã§ãã
[root@server ~]# uname -r
5.14.0-284.11.1.el9_2.x86_64
3 podmanã®ã¤ã³ã¹ãã¼ã«æ¹æ³
podmanããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ãã¾ãã
[root@server ~]# dnf -y install podman
podmanã³ãã³ãã®çæ°ã確èªãã¾ãã
[root@server ~]# podman -v
podman version 4.9.4-rhel
4 ãã£ã¬ã¯ãã£ã
ãã£ã¬ã¯ãã£ãã¨ã¯ãContainerfileå
ã«è¨è¿°ããã³ãã³ãã®ãã¨ã§ãããã£ã¬ã¯ãã£ãã使ç¨ããã¨ãã³ã³ããã«ã½ããã¦ã§ã¢ãã¤ã³ã¹ãã¼ã«ãããããã¹ãã®ãã¡ã¤ã«ãã³ã³ããå
ã«ã³ãã¼ããããããã¨ãã§ãã¾ãã
ãã£ã¬ã¯ãã£ã |
æ¦è¦ |
FROM |
ãã¼ã¹ã¨ãªãã³ã³ããã¤ã¡ã¼ã¸ãæå®ãã¾ã |
COPY |
ãã¹ãã®ãã¡ã¤ã«ããã£ã¬ã¯ããªãURLãã³ã³ããã«ã³ãã¼ãã¾ããADD ã¨ç°ãªãç¹ã¯ããªã¢ã¼ãURL ã®æå®ä¸å¯ãã¢ã¼ã«ã¤ããã¡ã¤ã«ãèªåã§å±éãã¾ãã |
ADD |
ãã¹ãã®ãã¡ã¤ã«ããã£ã¬ã¯ããªãURLãã³ã³ããã«ã³ãã¼ãã¾ããADDã¯COPYã«æ¯ã¹å¤æ©è½ã§ãããã·ã³ãã«ãªã³ãã¼ã«ã¯COPYã使ããã¨ãæ¨å¥¨ããã¦ããããã§ã |
RUN |
ã¤ã¡ã¼ã¸ã®ãã«ãä¸ã«å®è¡ããã³ãã³ããæå®ãã¾ããå
·ä½çã«ã¯ãã¤ã¡ã¼ã¸ã®æ§ç¯ã«å¿
è¦ãªã½ããã¦ã§ã¢ã®ã¤ã³ã¹ãã¼ã«ãè¨å®å¤æ´ããã¡ã¤ã«ã®ãã¦ã³ãã¼ããªã©ãè¡ããã¨ãã§ãã¾ã |
ENTRYPOINT |
ã³ã³ãããèµ·åããã¨ãã«å®è¡ãããã¡ã¤ã³ããã»ã¹ãæå®ããããã«ä½¿ç¨ãã¾ã |
CMD |
ã³ã³ãããèµ·åããã¨ãã«å®è¡ããã³ãã³ãã®ããã©ã«ãã®ãã©ã¡ã¼ã¿ãæå®ãã¾ã |
EXPOSE |
ã³ã³ããããã±ãããå¾
ã¡åãããã¼ãçªå·ãæå®ããããã«ä½¿ç¨ãã¾ãããã±ããã¯listenã·ã¹ãã ã³ã¼ã«ãå®è¡ãã¦å¾
ã¡åãã¾ã |
ENV |
ã³ã³ããå
ã§ç°å¢å¤æ°ãè¨å®ããããã«ä½¿ç¨ãã¾ããããã«ãããã³ã³ããå
ã®ããã»ã¹ãå©ç¨ããç°å¢å¤æ°ãå®ç¾©ã§ãã¾ããENV ãã£ã¬ã¯ãã£ãã§è¨å®ããç°å¢å¤æ°ã¯ãçµæã¨ãã¦ä½æãããã¤ã¡ã¼ã¸ããå®è¡ããã³ã³ããã§ãç¶æããã¾ã |
LABEL |
ã¤ã¡ã¼ã¸ã«ä»»æã®ã©ãã«ï¼ãã¼ã»ããªã¥ã¼å½¢å¼ã§æå®ï¼ãä»ããããã«ä½¿ç¨ãã¾ããã©ãã«ã¯ãããã¸ã§ã¯ãã§ã¤ã¡ã¼ã¸ã管çããããã«ä½¿ç¨ãã¾ãä¾ãã°ã誰ãä½æããã¤ã¡ã¼ã¸ãªã®ãã¨ãã£ãæ
å ±ãã¤ã¡ã¼ã¸ã«ä»ãããã¨ãã§ãã¾ã |
WORKDIR |
ã³ã³ããå
ã®ä½æ¥ãã£ã¬ã¯ããªãå¤æ´ããããã«ä½¿ç¨ãã¾ã |
USER |
USERãã£ã¬ã¯ãã£ãã§æå®ããã¦ã¼ã¶ã¼æ¨©éã§ã³ã³ããå
ã®ããã»ã¹ãã³ãã³ããå®è¡ãã¾ã |
5 FROMãã£ã¬ã¯ãã£ãã®ä½¿ãæ¹
ã¤ã¡ã¼ã¸ã®åæç¶æ
ã確èªãã¾ãã
[user1@server ~]$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
Containerfileã使ã£ã¦ã次ã®å
容ã®ã¤ã¡ã¼ã¸ãä½æãã¾ãã
ã»ãã¼ã¹ã¤ã¡ã¼ã¸ã«AlmaLinuxã使ç¨ããï¼FROM ï¼
[user1@server ~]$ vi Containerfile
[user1@server ~]$ cat Containerfile
FROM docker.io/library/almalinux
ã¤ã¡ã¼ã¸ããã«ããã¾ãã-tï¼ã¿ã°ï¼ãªãã·ã§ã³ã¯ããã«ãããã¤ã¡ã¼ã¸ã®ååï¼test_imageï¼ãæå®ãã¾ããæå¾ã«æå®ãããã©ã¡ã¼ã¿ã¯ãContainerfile ãæ ¼ç´ãããã£ã¬ã¯ããªã示ãã¾ããããã§ã¯ããªãªãï¼.ï¼ãæå®ãã¦ãããããpodman ã³ãã³ããå®è¡ããå ´æã¨åããã£ã¬ã¯ããªã« Containerfile ããããã¨ãæå³ãã¦ãã¾ãã
[user1@server ~]$ podman build -t test_image .
STEP 1/1: FROM docker.io/library/almalinux
Trying to pull docker.io/library/almalinux:latest...
Getting image source signatures
Copying blob 587e68e1d836 done |
Copying config 8109fa501e done |
Writing manifest to image destination
COMMIT test_image
--> 8109fa501eaf
Successfully tagged localhost/test_image:latest
Successfully tagged docker.io/library/almalinux:latest
8109fa501eaf5af622946e7c5c033cb7aef816c3267b1c17c7b62b34fea099a5
ã¤ã¡ã¼ã¸ã確èªããã¨ãã¤ã¡ã¼ã¸ï¼test_imageï¼ãä½æããããã¨ããããã¾ãã
[user1@server ~]$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/test_image latest 8109fa501eaf 5 weeks ago 191 MB
docker.io/library/almalinux latest 8109fa501eaf 5 weeks ago 191 MB
次ã®æ¤è¨¼ã®ãããã¤ã¡ã¼ã¸ãåé¤ãã¾ãã
[user1@server ~]$ podman rmi -f $(podman images -q)
6 COPY/ADDãã£ã¬ã¯ãã£ãã®ä½¿ãæ¹
6.1 COPY ãã£ã¬ã¯ãã£ãã®ä½¿ãæ¹
ãã¹ãããã³ã³ããã«ã³ãã¼ãããã¡ã¤ã«ãä½æãã¾ãã
[user1@server ~]$ vi test.sh
[user1@server ~]$ cat test.txt
12345
ä½æãããã¡ã¤ã«ã®ææè
ã¨ææã°ã«ã¼ãã確èªãã¾ãããã¹ãç°å¢ã§ã¯ãuser1 ã§ãã¡ã¤ã«ãä½æãã¦ãããããææè
ããã³ææã°ã«ã¼ãã user1 ã«ãªã£ã¦ãããã¨ã確èªã§ãã¾ãã
[user1@server ~]$ ls -l test.txt
-rw-r--r--. 1 user1 user1 6 7æ 8 20:20 test.txt
Containerfileã使ã£ã¦ã次ã®å
容ã®ã¤ã¡ã¼ã¸ãä½æãã¾ãã
ã»ãã¼ã¹ã¤ã¡ã¼ã¸ã«AlmaLinuxã使ç¨ããï¼FROM ï¼
ã»ãã¹ãã§ä½æãããã¡ã¤ã«ï¼test.txtï¼ãã³ã³ããã® /tmpã«ã³ãã¼ããï¼COPY )
[user1@server ~]$ vi Containerfile
[user1@server ~]$ cat Containerfile
FROM docker.io/library/almalinux
COPY test.txt /tmp
ã¤ã¡ã¼ã¸ããã«ããã¾ãã
[user1@server ~]$ podman build -t test_image .
ãã«ãããã¤ã¡ã¼ã¸ã確èªãã¾ãã
[user1@server ~]$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/test_image latest 4d4957e1ef46 2 seconds ago 191 MB
docker.io/library/almalinux latest 8109fa501eaf 6 weeks ago 191 MB
ãã«ãããã¤ã¡ã¼ã¸ï¼test_imageï¼ããã³ã³ãããèµ·åãã¾ãã
[user1@server ~]$ podman run -dit --name test1 test_image
ce501fb90adaa9828d45f3ad02fb2e24b242048228f42dbc095cfb4fa1265fcc
ã³ã³ããã§bashãå®è¡ãã¾ãã
[user1@server ~]$ podman exec -it test1 bash
[root@ce501fb90ada /]#
ãã¹ãããã³ã³ããã«ã³ãã¼ãããã¡ã¤ã«ã確èªãã¾ãããã¡ã¤ã«ã®ææè
ãææã°ã«ã¼ãã¯rootã«ãªã£ã¦ãã¾ãããã¡ã¤ã«ã®ææè
ãææã°ã«ã¼ãã®å¤æ´æ¹æ³ã¯å¾è¿°ãã¾ãã
[root@ce501fb90ada /]# ls -l /tmp/test.txt
-rw-r--r--. 1 root root 6 Jul 8 11:20 /tmp/test.txt
ã³ã³ããããã¬ãã¾ãã
[root@ce501fb90ada /]# exit
exit
次ã®æ¤è¨¼ã®ãããã³ã³ãããã¤ã¡ã¼ã¸ãåé¤ãã¾ãã
[user1@server ~]$ podman rm test1 --force
[user1@server ~]$ podman rmi -f $(podman images -q)
次ã¯ãã³ã³ããå
ã«ã³ãã¼ãããã¡ã¤ã«ã®ææè
ãææã°ã«ã¼ããuser1ã«å¤æ´ãã¦ã¿ã¾ãã
[user1@server ~]$ cat Containerfile
FROM docker.io/library/almalinux
RUN adduser user1
COPY test.txt /tmp
RUN chown user1:user1 /tmp/test.txt
ã³ã³ãããèµ·åãã¦ãã¡ã¤ã«ï¼/tmp/test.txtï¼ã®ææè
ããã³ææã°ã«ã¼ãã確èªãã㨠user1 ã«å¤æ´ããã¦ãããã¨ã確èªã§ãã¾ãã
[root@45abd84d6676 /]# ls -l /tmp/test.txt
-rw-r--r--. 1 user1 user1 6 Jul 8 11:20 /tmp/test.txt
次ã®æ¤è¨¼ã®ãããã³ã³ãããã¤ã¡ã¼ã¸ãåé¤ãã¾ãã
[user1@server ~]$ podman rm test1 --force
[user1@server ~]$ podman rmi -f $(podman images -q)
6.2 ADDãã£ã¬ã¯ãã£ãã®ä½¿ãæ¹
6.2.1 å§ç¸®ãã¡ã¤ã«ã®ã³ãã¼
(1) äºåæºåï¼å§ç¸®ãã¡ã¤ã«ã®ä½æï¼
ãã¹ãç¨ã®ãã¡ã¤ã«ãä½æãã¾ãã
[user1@server ~]$ vi test.txt
[user1@server ~]$ cat test.txt
12345
ãã¹ãç¨ã®å§ç¸®ãã¡ã¤ã«ãä½æãã¾ãã
[user1@server ~]$ tar -zcvf test.tar.gz test.txt
test.txt
(2) ADDãã£ã¬ã¯ãã£ãã®åä½ç¢ºèª
Containerfileã使ã£ã¦ã次ã®å
容ã®ã¤ã¡ã¼ã¸ãä½æãã¾ãã
ã»ãã¼ã¹ã¤ã¡ã¼ã¸ã«AlmaLinuxã使ç¨ããï¼FROM ï¼
ã»ãã¹ãã§ä½æããå§ç¸®ãã¡ã¤ã«ï¼test.tar.gz ï¼ã解åãã¦ã³ã³ããã®/tmpã«ã³ãã¼ããï¼ADD)
[user1@server ~]$ cat Containerfile
FROM docker.io/library/almalinux
ADD test.tar.gz /tmp/
ã¤ã¡ã¼ã¸ããã«ããã¾ãã
[user1@server ~]$ podman build -t test_image .
ãã«ãããã¤ã¡ã¼ã¸ï¼test_imageï¼ããã³ã³ãããèµ·åãã¾ãã
[user1@server ~]$ podman run -dit --name test1 test_image
23fb9dc21856fd4dec4d02f1310a74d02468213c456dc66dd270bd39ed3b43ca
ã³ã³ããã§bashãå®è¡ãã¾ãã
[user1@server ~]$ podman exec -it test1 bash
[root@23fb9dc21856 /]#
ADD ãã£ã¬ã¯ãã£ãã¯å§ç¸®ãã¡ã¤ã«ã解åãã¦ã³ã³ããã«ã³ãã¼ããããããã¹ãã§ä½æããå§ç¸®ãã¡ã¤ã«ãã³ã³ããå
ã§è§£åããããã¨ã確èªã§ãã¾ãã
[root@23fb9dc21856 /]# cat /tmp/test.txt
12345
ã³ã³ããããã¬ãã¾ãã
[root@23fb9dc21856 /]# exit
exit
次ã®æ¤è¨¼ã®ãããã³ã³ãããã¤ã¡ã¼ã¸ãåé¤ãã¾ãã
[user1@server ~]$ podman rm test1 --force
[user1@server ~]$ podman rmi -f $(podman images -q)
ãã¹ãã§ãã¹ãç¨ã®ãã£ã¬ã¯ããªããã¡ã¤ã«ãä½æãã¾ãã
[user1@server ~]$ mkdir host_dir
[user1@server ~]$ echo "12345" > host_dir/test1.txt
[user1@server ~]$ echo "67890" > host_dir/test2.txt
Containerfileã使ã£ã¦ã次ã®å
容ã®ã¤ã¡ã¼ã¸ãä½æãã¾ãã
ã»ï¼FROM ï¼
ã»ãã¹ãã§ä½æãããã£ã¬ã¯ããªï¼host_dir ï¼ãã³ã³ããã®/tmpã«ã³ãã¼ããï¼ADD)
[user1@server ~]$ cat Containerfile
FROM docker.io/library/almalinux
ADD host_dir /tmp
ã¤ã¡ã¼ã¸ããã«ããã¾ãã
[user1@server ~]$ podman build -t test_image .
ãã«ãããã¤ã¡ã¼ã¸ï¼test_imageï¼ããã³ã³ãããèµ·åãã¾ãã
[user1@server ~]$ podman run -dit --name test1 test_image
ba931b22c906117c514d604b1a556cbc933665b4e39e3500d8e081a0b0c37183
ã³ã³ããã§bashãå®è¡ãã¾ãã
[user1@server ~]$ podman exec -it test1 bash
[root@ba931b22c906 /]#
ã³ã³ããã§/tmpé
ä¸ã®ãã¡ã¤ã«ã確èªãã¾ãããã¹ãã®host_dir é
ä¸ã«ä½æãããã¡ã¤ã«ãã³ã³ããã®/tmpé
ä¸ã«ã³ãã¼ããã¦ãããã¨ã確èªã§ãã¾ãã
[root@ba931b22c906 /]# ls -l /tmp/*
-rw-r--r--. 1 root root 6 Jul 14 00:24 /tmp/test1.txt
-rw-r--r--. 1 root root 6 Jul 14 00:24 /tmp/test2.txt
ã³ã³ããããã¬ãã¾ãã
[root@ba931b22c906 /]# exit
exit
次ã®æ¤è¨¼ã®ãããã³ã³ãããã¤ã¡ã¼ã¸ãåé¤ãã¾ãã
[user1@server ~]$ podman rm test1 --force
[user1@server ~]$ podman rmi -f $(podman images -q)
7 RUNãã£ã¬ã¯ãã£ãã®ä½¿ãæ¹
Containerfileã使ã£ã¦ã次ã®å
容ã®ã¤ã¡ã¼ã¸ãä½æãã¾ãã
ã»ãã¼ã¹ã¤ã¡ã¼ã¸ã«AlmaLinuxã使ç¨ããï¼FROM ï¼
ã»iprouteããã±ã¼ã¸ãã¤ã¡ã¼ã¸ã«ã¤ã³ã¹ãã¼ã«ããï¼RUN ï¼
[user1@server ~]$ cat Containerfile
FROM docker.io/library/almalinux
RUN dnf -y install iproute
ã¤ã¡ã¼ã¸ããã«ããã¾ãã
[user1@server ~]$ podman build -t test_image .
ãã«ãããã¤ã¡ã¼ã¸ã確èªãã¾ãã
[user1@server ~]$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/test_image latest f28aa2f7799c 54 seconds ago 238 MB
docker.io/library/almalinux latest 8109fa501eaf 5 weeks ago 191 MB
ãã«ãããã¤ã¡ã¼ã¸ï¼test_imageï¼ããã³ã³ãããèµ·åãã¾ãã
[user1@server ~]$ podman run -dit --name test1 test_image
db3023492a4caf5ce9b0b653bc5b2ecb6cba5065ccf68de12e6ed268bc44631c
ã³ã³ããã§bashãå®è¡ãã¾ãã
[user1@server ~]$ podman exec -it test1 bash
[root@db3023492a4c /]#
ã³ã³ããã§ããã±ã¼ã¸ã確èªããã¨ãiprouteããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ããã¦ãããã¨ã確èªã§ãã¾ãã
[root@db3023492a4c /]# rpm -qa|grep iproute
iproute-6.2.0-6.el9_4.x86_64
ã³ã³ããããã¬ãã¾ãã
[root@db3023492a4c /]# exit
exit
次ã®æ¤è¨¼ã®ãããã³ã³ãããã¤ã¡ã¼ã¸ãåé¤ãã¾ãã
[user1@server ~]$ podman rm test1 --force
[user1@server ~]$ podman rmi -f $(podman images -q)
8 ENTRYPOINT/CMDãã£ã¬ã¯ãã£ãã®ä½¿ãæ¹
Dockerfile リファレンス — Docker-docs-ja 24.0 ドキュメントã«ããã¨ãENTRYPOINTãã£ã¬ã¯ãã£ãã¯ä»¥ä¸ã®æ¸å¼ãããã¾ãã exec å½¢å¼ãæ¨å¥¨ããã¦ããããã§ããããã§ãããã£ã¬ã¯ãã£ãã¯exec å½¢å¼ã使ç¨ãã¾ãã
- exec å½¢å¼ï¼æ¨å¥¨ããã¦ããå½¢å¼ï¼
ENTRYPOINT ["å®è¡ãã¡ã¤ã«", "ãã©ã¡ã¼ã¿1", "ãã©ã¡ã¼ã¿2"]
ENTRYPOINT ã³ãã³ã ãã©ã¡ã¼ã¿1 ãã©ã¡ã¼ã¿2
Containerfileã使ã£ã¦ã次ã®å
容ã®ã¤ã¡ã¼ã¸ãä½æãã¾ãã
ã»ãã¼ã¹ã¤ã¡ã¼ã¸ã«AlmaLinuxã使ç¨ããï¼FROM ï¼
ã»ã³ã³ããèµ·åæã«å®è¡ããããã°ã©ã ãæå®ããï¼ENTRYPOINT )
ã»ENTRYPOINT ã§æå®ããã³ãã³ãã®ãã©ã¡ã¼ã¿ãæå®ããï¼CMD ï¼
[user1@server ~]$ vi Containerfile
[user1@server ~]$ cat Containerfile
FROM docker.io/library/almalinux
ENTRYPOINT ["ping","-c","1"]
CMD ["example.com"]
ã¤ã¡ã¼ã¸ããã«ããã¾ãã
[user1@server ~]$ podman build -t test_image .
ãã1ã¤ã¿ã¼ããã«ãéãã¦tcpdumpãå®è¡ãã¾ãã-iã¯ã¤ã³ã¿ãã§ã¼ã¹åãæå®ãã¾ããã使ãã®ç°å¢ã«åããã¦é©å®å¤æ´ãã¦ãã ããããªãããtcpdumpã®è©³ç´°ãªä½¿ãæ¹ã¯ãtcpdumpの使い方(基本編) - hana_shinのLinux技術ブログãåç
§ãã¦ãã ããã
[root@server ~]# tcpdump -i enp1s0 icmp -n
ãã«ãããã¤ã¡ã¼ã¸ï¼test_imageï¼ããã³ã³ãããèµ·åãã¾ãã
[user1@server ~]$ podman run --name test1 test_image
tcpdumpã®å®è¡çµæã確èªããã¨ãexample.comï¼93.184.215.14ï¼å®ã¦ã®pingå®è¡çµæã確èªã§ãã¾ãã
[root@server ~]# tcpdump -i enp1s0 icmp -n
22:21:10.429828 IP 192.168.122.87 > 93.184.215.14: ICMP echo request, id 20, seq 1, length 64
22:21:10.524670 IP 93.184.215.14 > 192.168.122.87: ICMP echo reply, id 20, seq 1, length 64
digã³ãã³ãã§ç¢ºèªããã¨ãexample.comã®IPã¢ãã¬ã¹ã¯93.184.215.14ã§ãããã¨ã確èªã§ãã¾ãããªããdigã³ãã³ãã®ä½¿ãæ¹ã¯ãdigコマンドの使い方 - hana_shinのLinux技術ブログãåç
§ãã¦ãã ããã
[root@server ~]# dig example.com +short
93.184.215.14
次ã®æ¤è¨¼ã®ãããã³ã³ãããåé¤ãã¾ãã
[user1@server ~]$ podman rm test1 --force
次ã«ãã³ã³ããèµ·åæã«ãã©ã¡ã¼ã¿ãæ示çã«æå®ãã¾ããæå®ãããã©ã¡ã¼ã¿ã¯ãããã©ã«ãã²ã¼ãã¦ã§ã¤ã®IPã¢ãã¬ã¹ï¼192.168.122.1ï¼ã§ãã
[user1@server ~]$ podman run --name test1 test_image 192.168.122.1
tcpdumpã®å®è¡çµæã確èªããã¨ãexample.comã«å¯¾ããpingã®çµæã§ã¯ãªããããã©ã«ãã²ã¼ãã¦ã§ã¤ã®IPã¢ãã¬ã¹ï¼192.168.122.1ï¼ã«å¯¾ããpingã®çµæã§ãããã¨ã確èªã§ãã¾ããã¤ã¾ããCMDã§æå®ãããã©ã¡ã¼ã¿ãã³ã³ããèµ·åæã«æå®ãããã©ã¡ã¼ã¿ã§ä¸æ¸ãããããã¨ããããã¾ãã
[root@server ~]# tcpdump -i enp1s0 icmp -n
22:27:21.353640 IP 192.168.122.87 > 192.168.122.1: ICMP echo request, id 24, seq 1, length 64
22:27:21.353973 IP 192.168.122.1 > 192.168.122.87: ICMP echo reply, id 24, seq 1, length 64
次ã®æ¤è¨¼ã®ãããã³ã³ãããã¤ã¡ã¼ã¸ãåé¤ãã¾ãã
[user1@server ~]$ podman rm test1 --force
[user1@server ~]$ podman rmi -f $(podman images -q)
9 EXPOSEãã£ã¬ã¯ãã£ãã®ä½¿ãæ¹
Containerfileã使ã£ã¦ã次ã®å
容ã®ã¤ã¡ã¼ã¸ãä½æãã¾ãã
ã»ãã¼ã¹ã¤ã¡ã¼ã¸ã«AlmaLinuxã使ç¨ããï¼FROM ï¼
ã»ã³ã³ããã®httpdã80çªãã¼ãã§ãªãã¹ã³ããï¼EXPOSE )
[user1@server ~]$ vi Containerfile
[user1@server ~]$ cat Containerfile
FROM httpd:latest
EXPOSE 80
ã¤ã¡ã¼ã¸ããã«ããã¾ãã
[user1@server ~]$ podman build -t test_image .
ä½æããã¤ã¡ã¼ã¸ã確èªãã¾ãã
[user1@server ~]$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/test_image latest 72416f67c6ae 36 seconds ago 152 MB
docker.io/library/httpd latest c0c20df5e7be 5 days ago 152 MB
ãã«ãããã¤ã¡ã¼ã¸ï¼test_imageï¼ããã³ã³ãããèµ·åãã¾ãããã®ã¨ãã-pãªãã·ã§ã³ã使ã£ã¦ããã¹ãã®8080çªãã¼ãã¸ã®ã¢ã¯ã»ã¹ãã³ã³ããã®80çªãã¼ãã«ãããã³ã°ãã¾ãã
[user1@server ~]$ podman run -d -p 8080:80 --name test1 test_image
1f8a374faf80f2bd28b48710de04b74f8d2cdc2ef98489f4e6d027136fc271d4
ãã¼ãã®ãããã³ã°ã確èªãã¾ãããã¹ãã®ä»»æï¼0.0.0.0ï¼ã®IPã¢ãã¬ã¹ã«å¯¾ãã8080çªãã¼ãã¸ã®ã¢ã¯ã»ã¹ããã³ã³ããã®80çªãã¼ãã¸ã®ã¢ã¯ã»ã¹ã«å¤æããããã¨ã確èªã§ãã¾ãã
[user1@server ~]$ podman port test1
80/tcp -> 0.0.0.0:8080
curlã³ãã³ããå®è¡ãã¦ãã¹ãã®8080çªãã¼ãã«ã¢ã¯ã»ã¹ãã¦ã¿ã¾ããã³ã³ããã®httpdããã®å¿çã確èªãããã¨ãã§ãã¾ãã
[user1@server ~]$ curl http://localhost:8080
<html><body><h1>It works!</h1></body></html>
ã³ã³ããããã¬ãã¾ãã
[root@db3023492a4c /]# exit
exit
次ã®æ¤è¨¼ã®ãããã³ã³ãããã¤ã¡ã¼ã¸ãåé¤ãã¾ãã
[user1@server ~]$ podman rm test1 --force
[user1@server ~]$ podman rmi -f $(podman images -q)
10 ENVãã£ã¬ã¯ãã£ãã®ä½¿ãæ¹
Containerfileã使ã£ã¦ã次ã®å
容ã®ã¤ã¡ã¼ã¸ãä½æãã¾ãã
ã»ãã¼ã¹ã¤ã¡ã¼ã¸ã«AlmaLinuxã使ç¨ããï¼FROM ï¼
ã»ç°å¢å¤æ°ï¼TESTï¼ã«æååï¼"Hello, World!"ï¼ãè¨å®ããï¼ENV )
ã»ç°å¢å¤æ°ã«è¨å®ããæååãechoã³ãã³ãã§åºåããï¼CMD ï¼
[user1@server ~]$ cat Containerfile
FROM docker.io/library/almalinux
ENV TEST="Hello, World!"
CMD echo $TEST
ã¤ã¡ã¼ã¸ããã«ããã¾ãã
[user1@server ~]$ podman build -t test_image .
ãã«ãããã¤ã¡ã¼ã¸ï¼test_imageï¼ããã³ã³ãããèµ·åãã¾ããã³ã³ãããèµ·åããéã«ãç°å¢å¤æ°TESTã«è¨å®ããæååãåºåããããã¨ã確èªã§ãã¾ãã
[user1@server ~]$ podman run --name test1 test_image
Hello, World!
ãã¨å§æ«ããã¾ãã
[user1@server ~]$ podman rm test1
test1
ã³ã³ãããå®è¡ããéã«ãè¨å®ãããç°å¢å¤æ°ãä¸æ¸ããããã¨ãã§ãã¾ããä¾ãã°ãç°å¢å¤æ°TESTã«"bye"ãè¨å®ãã¦ã³ã³ãããèµ·åãã¦ã¿ã¾ãããã®å ´åãã³ã³ãããèµ·åããéã«ãâHello, World!âã§ã¯ãªã"bye"ãåºåããããã¨ã確èªã§ãã¾ãã
[user1@server ~]$ podman run -e TEST=bye --name test1 test_image
bye
次ã®æ¤è¨¼ã®ãããã³ã³ãããã¤ã¡ã¼ã¸ãåé¤ãã¾ãã
[user1@server ~]$ podman rm test1 --force
[user1@server ~]$ podman rmi -f $(podman images -q)
11 LABELãã£ã¬ã¯ãã£ãã®ä½¿ãæ¹
Containerfileã使ã£ã¦ã次ã®å
容ã®ã¤ã¡ã¼ã¸ãä½æãã¾ãã
ã»ãã¼ã¹ã¤ã¡ã¼ã¸ã«AlmaLinuxã使ç¨ããï¼FROM ï¼
ã»ã¤ã¡ã¼ã¸ã«ã©ãã«ãã¤ããï¼LABEL )ãã©ãã«ã®å
容ã¯ãä½æè
ï¼maintainerï¼ãã¤ã¡ã¼ã¸ã®ãã¼ã¸ã§ã³ï¼versionï¼ãã¤ã¡ã¼ã¸ã®ä½ææ¥ï¼2024/7/10ï¼
[user1@server ~]$ cat Containerfile
FROM docker.io/library/almalinux
LABEL maintainer="[email protected]"
LABEL version="1.0"
LABEL created="2024-07-10"
ã¤ã¡ã¼ã¸ããã«ããã¾ãã
[user1@server ~]$ podman build -t test_image .
Podmanã®inspectã³ãã³ãã¨jqã³ãã³ããä½µç¨ãã¦ãã¤ã¡ã¼ã¸ã«ä»ããã©ãã«ã確èªãã¦ã¿ã¾ãããªããio.buildah.versionã¯Buildahã®ãã¼ã¸ã§ã³æ
å ±ã示ãã¦ããããã«ããã¼ã«ãèªåçã«è¿½å ãããã®ã§ãã
[user1@server ~]$ podman inspect test_image --format '{{json .Config.Labels}}' | jq
{
"created": "2024-07-10",
"io.buildah.version": "1.33.7",
"maintainer": "[email protected]",
"version": "1.0"
}
次ã®æ¤è¨¼ã®ãããã¤ã¡ã¼ã¸ãåé¤ãã¾ãã
[user1@server ~]$ podman rmi -f $(podman images -q)
12 WORKDIRãã£ã¬ã¯ãã£ãã®ä½¿ãæ¹
Containerfileã使ã£ã¦ã次ã®å
容ã®ã¤ã¡ã¼ã¸ãä½æãã¾ãã
ã»ãã¼ã¹ã¤ã¡ã¼ã¸ã«AlmaLinuxã使ç¨ããï¼FROM ï¼
ã»ä½æ¥ãã£ã¬ã¯ããªã /etc ã«å¤æ´ããï¼WORKDIR )
ã»ãã¡ã¤ã«ï¼test.confï¼ã«æååãæ¸ãè¾¼ãï¼RUN ï¼
[user1@server ~]$ cat Containerfile
FROM docker.io/library/almalinux
WORKDIR /etc
RUN echo "Hello" > test.conf
ã¤ã¡ã¼ã¸ããã«ããã¾ãã
[user1@server ~]$ podman build -t test_image .
ãã«ãããã¤ã¡ã¼ã¸ï¼test_imageï¼ããã³ã³ãããèµ·åãã¾ãã
[user1@server ~]$ podman run -dit --name test1 test_image
734466e173c07719688d9deb0304eacc4ece68bdb3cbc58685b47954142c8eae
ã³ã³ããã§bashãå®è¡ãã¾ãã
[user1@server ~]$ podman exec -it test1 bash
[root@734466e173c0 etc]#
ä½æ¥ãã£ã¬ã¯ããªã確èªãã㨠/etc ã§ãããã¨ã確èªã§ãã¾ãã
[root@734466e173c0 etc]# pwd
/etc
ãã¡ã¤ã«ï¼test.confï¼ã«æ¸ãè¾¼ãã å
容ã確èªããã¨ã"Hello"ã§ãããã¨ã確èªã§ãã¾ãã
[root@734466e173c0 etc]# cat test.conf
Hello
ã³ã³ããããã¬ãã¾ãã
[root@734466e173c0 etc]# exit
exit
次ã®æ¤è¨¼ã®ãããã³ã³ãããã¤ã¡ã¼ã¸ãåé¤ãã¾ãã
[user1@server ~]$ podman rm test1 --force
[user1@server ~]$ podman rmi -f $(podman images -q)
13 USERãã£ã¬ã¯ãã£ãã®ä½¿ãæ¹
Containerfileã使ã£ã¦ã次ã®å
容ã®ã¤ã¡ã¼ã¸ãä½æãã¾ãã
ã»ãã¼ã¹ã¤ã¡ã¼ã¸ã«AlmaLinuxã使ç¨ããï¼FROM ï¼
ã»ã¦ã¼ã¶ã¼ï¼user2ï¼ãä½æããï¼RUN )
ã»å®è¡ã¦ã¼ã¶ã¼ãuser2ã«å¤æ´ããï¼USER ï¼
ã»ä½æ¥ãã£ã¬ã¯ããªã/home/user2ã«å¤æ´ããï¼USER ï¼
[user1@server ~]$ cat Containerfile
FROM docker.io/library/almalinux
RUN adduser user2
USER user2
WORKDIR /home/user2
ã¤ã¡ã¼ã¸ããã«ããã¾ãã
[user1@server ~]$ podman build -t test_image .
ãã«ãããã¤ã¡ã¼ã¸ï¼test_imageï¼ããã³ã³ãããèµ·åãã¾ãã
[user1@server ~]$ podman run -dit --name test1 test_image
ae3345f70a53062894ff5b050ff48fe7225553d0799d97f2e38baddee92a1692
ã³ã³ããã§bashãå®è¡ãã¾ãã
[user1@server ~]$ podman exec -it test1 bash
[user2@ae3345f70a53 ~]$
idã³ãã³ãã使ç¨ãã¦ã¦ã¼ã¶ã¼åã確èªãã¦ã¿ã¾ããã¦ã¼ã¶åãuser2ã§ãããã¨ã確èªã§ãã¾ãã
[user2@ae3345f70a53 ~]$ id
uid=1000(user2) gid=1000(user2) groups=1000(user2)
次ã«ãpwdã³ãã³ãã使ç¨ãã¦ç¾å¨ã®ä½æ¥ãã£ã¬ã¯ããªã確èªããã¨ãä½æ¥ãã£ã¬ã¯ããªã/home/user2ã§ãããã¨ã確èªã§ãã¾ãã
[user2@ae3345f70a53 ~]$ pwd
/home/user2
ã³ã³ããããã¬ãã¾ãã
[user2@ae3345f70a53 ~]$ exit
exit
次ã®æ¤è¨¼ã®ãããã³ã³ãããã¤ã¡ã¼ã¸ãåé¤ãã¾ãã
[user1@server ~]$ podman rm test1 --force
[user1@server ~]$ podman rmi -f $(podman images -q)
Y åèå³æ¸
ä»åã®è¨äºå·çã«ãããåèã«ããå³æ¸ã¯ä»¥ä¸ã®ãã®ã§ãã
|
c.scripts[c.scripts.length-2];(b[a].q=b[a].q |
|
[]).push(arguments)}; |
c.getElementById(a)||(d=c.createElement(f),d.src=g,
d.id=a,e=c.getElementsByTagName("body")[0],e.appendChild(d))})
(window,document,"script","//dn.msmstatic.com/site/cardlink/bundle.js?20220329","msmaflink");
msmaflink({"n":"Software Design (ã½ããã¦ã§ã¢ãã¶ã¤ã³) 2023å¹´11æå· [éèª]","b":"","t":"","d":"https:\/\/m.media-amazon.com","c_p":"","p":["\/images\/I\/51gnbOVIwuL._SL500_.jpg"],"u":{"u":"https:\/\/www.amazon.co.jp\/dp\/B0CKF3J1M9","t":"amazon","r_v":""},"v":"2.1","b_l":[{"id":1,"u_tx":"Amazonã§è¦ã","u_bc":"#f79256","u_url":"https:\/\/www.amazon.co.jp\/dp\/B0CKF3J1M9","a_id":3177459,"p_id":170,"pl_id":27060,"pc_id":185,"s_n":"amazon","u_so":1},{"id":5,"u_tx":"楽天å¸å ´ã§è¦ã","u_bc":"#f76956","u_url":"https:\/\/search.rakuten.co.jp\/search\/mall\/Software%20Design%20(%E3%82%BD%E3%83%95%E3%83%88%E3%82%A6%E3%82%A7%E3%82%A2%E3%83%87%E3%82%B6%E3%82%A4%E3%83%B3)%202023%E5%B9%B411%E6%9C%88%E5%8F%B7%20%5B%E9%9B%91%E8%AA%8C%5D\/","a_id":3177083,"p_id":54,"pl_id":27059,"pc_id":54,"s_n":"rakuten","u_so":2}],"eid":"ax2oE","s":"s"});
ãªã³ã¯
ãªã³ã¯
ãªã³ã¯
ãªã³ã¯
ãªã³ã¯
Software Design (ã½ããã¦ã§ã¢ãã¶ã¤ã³) 2023å¹´11æå· [éèª]
Dockerå®è·µã¬ã¤ã 第3ç impress top gearã·ãªã¼ãº