podman ์ docker ์ ํธํ๋๋ค. docker ์์ ์์ฑ๋ ์ด๋ฏธ์ง ๋ํ podman ์ ํตํด์ ์ฌ์ฉํ ์ ์๋ค.
docker ์ ๋นํด์ ์ฌ๋ฌ๊ฐ์ง ์ฅ์ ๋ค์ด ์๋ค.
- Ubuntu 22.04 LTS ์ค์น ํ์
- golang 1.18 ์ด์(1.16 ์ด์ ์ด๊ธดํ๋ฐ, 1.16 ์ผ๋ ์์ ์๋ ๋ฌธ์ ๊ฐ ๋ฐ์ํด์ ๊ทธ๋ฅ 1.18.1 ๋ก ์ ๋ฐ์ดํธ ํจ.)
- goland 20.01 ๋ฒ์ ์ฌ์ฉํ๊ณ ์์๋๋ฐ golang 1.18 goroot ์ค์ ์์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ฌ goland 22.01 ๋ฒ์ ์ผ๋ก ์ ๊ทธ๋ ์ด๋ ํจ.
- ํ์ฌ(22.04.28) podman ์ ubuntu ์ ์ต์ ๋ฒ์ ์ผ๋ก ์ค์นํ๋ฉด version ์ด 3.4.4 ์ด๋ค. ํ์ง๋ง ํ์ฌ ์ต์ ๋ฒ์ ์ 4.x ์ด๋ค.
- ๋ฐ์ธ๋ฉ์ ์ฝ๋์์ ์ฌ์ฉํ๋ ๋ฒ์ ๊ณผ ์ค์น๋์ด ์๋ podman ๋ฒ์ ์ด ์ผ์นํด์ผ ํ๋ค. ๋ง์ฝ ๋ค๋ฅผ์ ์๋ฌ ๋ฐ์ํ๋ค.
- podman bindings ์ฌ์ฉํ์ฌ ๊ฐ๋ฐ์ ๋ฐ๋์ go mod ์ฌ์ฉํด์ผ ํ๋ค. ์์ผ๋ฉด ๋ฌธ์ ๋ฐ์.
- podman ์ค์น
- podman ์ค์น ๋ฐ ์คํ ์์
- podman bindings
- podman trouble shooting
- podman Demo
- podman restapi manual
- ๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ
// podman ์ด๋ฏธ์ง ๊ฐ์ ธ์ค๊ธฐ
podman pull centos
// ์ด๋ฏธ์ง ๋ฆฌ์คํธ ํ์ธ
// podman image list ์ ๋์ผ
podman images
// ์ด๋ฏธ์ง run ์ํค๊ธฐ(์ปจํ
์ด๋ ์คํ์ํค๊ธฐ)
podman run -it --name cent centos /bin/sh
// container ๊ฐ ์คํ์ค์ด๊ณ /bin/bash ๋๋ /bin/sh ๋ฑ์ bash ๋ฑ์ด ์คํ๋์ด ์๋ค๋ฉด docker ์ ๊ฐ์ด attach ๋ก ์ ๊ทผํ ์ ์๋ค.
podman attach cent
// ๊ทธ๋ ์ง ์์ ๊ฒฝ์ฐ
podman exec -it [container-name or container-id] /bin/bash
// bind mount ์ํค๊ธฐ
podman run -v /opt:/opt -it --name centPrint01 centos /bin/sh
- ๋ชจ๋ ์ปจํ ์ด๋ ์ญ์
// ์ฌ๊ธฐ์ -q ์ต์
์ ์ปจํ
์ด๋ ์์ด๋๋ฅผ ํ์ค์ฉ ์ถ๋ ฅํด์ค๋ค.
// ๋ชจ๋ ์ปจํ
์ด๋๋ฅผ ์ค์ง์ํจ๋ค.
podman stop $(podman ps -a -q) ๋๋ podman stop $(podman ps -aq)
// ๋ชจ๋ ์ค์ง๋ ์ปจํ
์ด๋๋ฅผ ์ญ์ ํ๋ค.
podman rm $(podman ps -a -q)
// ์์ ๋๊ณผ์ ์ ๊ฑฐ์น์ง ์๊ณ -f ์ ์ฃผ๋ฉด ใ
๊ฐ์ ๋ก ์ค์ง์ํค๊ณ ์ญ์ ๊ฐ ๊ฐ๋ฅํ๋ค.
podman rm -f $(podman ps -a -q)
// ์ค์ง๋ ์ปจํ
์ด๋๋ง ์ญ์ ํ๋ค. (ํ
์คํธ ํด๋ณด์.)
podman container prune
- ๋ชจ๋ ์ด๋ฏธ์ง ์ญ์
podman image rm -f $(podman image ls -q)
- ์๋์ฝ๋๋ mariadb ์ด๋ฏธ์ง๋ฅผ ๊ฐ์ ธ์ฌ๋ ๋ฐ์ํ๋ค.
- ์ด์ ๋ํ ํด๊ฒฐ์ฑ ์ docker.io ๋ฅผ ๋ถ์ด๋ฉด ๋๋ค. ์ฐธ๊ณ
podman pull mariadb
> short-name "mariadb" did not resolve to an alias and no unqualified-search registries are defined in "/etc/containers/registries.conf"
podman pull docker.io/mariadb
Detached mode: run the container in the background and print the new container ID. The default is false.
At any time you can run podman ps in the other shell to view a list of the running containers.
You can reattach to a detached container with podman attach.
- podman run --dt or podman run -d
Pod ๊ด๋ จ (mesos container ๊ด๋ จํด์๋ ํ๋ฒ ์ ๋ฆฌํ์. https://mesos.apache.org/documentation/latest/)
- ์ฟ ๋ฒ๋คํฐ์ค์ pod ์ฐธ๊ณ , podman ์ pod ์ ๋น์ทํจ์ผ๋ก ์ฐธ๊ณ
- https://developers.redhat.com/blog/2019/01/29/podman-kubernetes-yaml#enough_teasing__show_me_the_goods ์ฝ๊ณ ์ง์ฐ๊ธฐ.
The podman generate kube command allows you to export your existing containers into Kubernetes Pod YAML. This YAML can then be imported into OpenShift or a Kubernetes cluster. The podman play kube does the opposite, it allows you to take a Kubernetes YAML and run it in Podman.
์ฌ๊ธฐ์ ๊ฐ์ ธ์ด-podman.io ๊ฒฐ๋ฃฉ ์ฟ ๋ฒ๋คํฑ์ค pod ๋ podman ์ pod ๋ผ๋ ์๋ฏธ ์ธ๊ฑฐ ๊ฐ๋ค. ์ข๋ ์ดํด๋ณด์.
- pod ์ ์๋ ์ปจํ ์ด๋๋ pod ๋ podman ์์ ์ญ์ ํ ์ ์๋ค. ์ฆ, podman rm -f ์ปจํ ์ด๋ID ๋ก ์ญ์ ํ ์ ์๋ค.
๋ชจ๋ Podman ํฌ๋์๋ ์ธํ๋ผ ์ปจํ ์ด๋๊ฐ ํฌํจ๋์ด ์์ต๋๋ค. ์ด ์ปจํ ์ด๋๋ ์๋ฌด ์์ ๋ ์ํํ์ง ์์ง๋ง ์ ์๊ธฐ ์ํ๋ก ์ ํ๋ฉ๋๋ค. ๊ทธ ๋ชฉ์ ์ ํฌ๋์ ์ฐ๊ฒฐ๋ ๋ค์์คํ์ด์ค๋ฅผ ๋ณด์ ํ๊ณ ํฌ๋๋งจ์ด ๋ค๋ฅธ ์ปจํ ์ด๋๋ฅผ ํฌ๋์ ์ฐ๊ฒฐํ ์ ์๋๋ก ํ๋ ๊ฒ์ ๋๋ค. ์ด๋ฅผ ํตํด POD ๋ด์์ ์ปจํ ์ด๋๋ฅผ ์์ ๋ฐ ์ค์งํ ์ ์์ผ๋ฉฐ ํฌ๋๋ ๊ณ์ ์คํ๋ฉ๋๋ค. ๊ธฐ๋ณธ ์ปจํ ์ด๋๊ฐ ํฌ๋๋ฅผ ์ ์ดํ๋ โโ๊ฒ์ฒ๋ผ ์ด๋ ๋ถ๊ฐ๋ฅํฉ๋๋ค. ๊ธฐ๋ณธ ์ธํ๋ผ ์ปจํ ์ด๋๋ k8s.gcr.io/pause์ด๋ฏธ์ง๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํฉ๋๋ค . ๋ฌ๋ฆฌ ๋ช ์ํ์ง ์๋ ํ ๋ชจ๋ ํฌ๋์๋ ๊ธฐ๋ณธ ์ด๋ฏธ์ง ๊ธฐ๋ฐ ์ปจํ ์ด๋๊ฐ ์์ต๋๋ค.
Pod๋ฅผ ๊ตฌ์ฑํ๋ ๋๋ถ๋ถ์ ์์ฑ์ ์ค์ ๋ก infra ์ปจํ ์ด๋์ ํ ๋น๋ฉ๋๋ค. ํฌํธ ๋ฐ์ธ๋ฉ, cgroup-parent ๊ฐ ๋ฐ ์ปค๋ ๋ค์์คํ์ด์ค๋ ๋ชจ๋ infra ์ปจํ ์ด๋์ ํ ๋น๋ฉ๋๋ค. ํฌ๋๊ฐ ์์ฑ๋๋ฉด ์ด๋ฌํ ์์ฑ์ด ์ธํ๋ผ ์ปจํ ์ด๋์ ํ ๋น๋๊ณ ๋ณ๊ฒฝํ ์ ์๊ธฐ ๋๋ฌธ์ ์ด๋ฅผ ์ดํดํ๋ ๊ฒ์ด ์ค์ํฉ๋๋ค. ์๋ฅผ ๋ค์ด ํฌ๋๋ฅผ ์์ฑํ ๋ค์ ๋์ค์ ์ ํฌํธ๋ฅผ ๋ฐ์ธ๋ฉํ๋ ์ปจํ ์ด๋๋ฅผ ์ถ๊ฐํ๊ธฐ๋ก ๊ฒฐ์ ํ๋ฉด ํฌ๋๋งจ์ ์ด๋ฅผ ์ํํ ์ ์์ต๋๋ค. ์ ์ปจํ ์ด๋๋ฅผ ์ถ๊ฐํ๊ธฐ ์ ์ ์ถ๊ฐ ํฌํธ ๋ฐ์ธ๋ฉ์ผ๋ก ํฌ๋๋ฅผ ๋ค์ ์์ฑํด์ผ ํฉ๋๋ค.
์์ ๋ค์ด์ด๊ทธ๋จ์์ ๊ฐ ์ปจํ ์ด๋ ์์ ์๋ ์์๋ฅผ ํ์ธํ์ญ์์ค. ์ด๊ฒ์ ์ปจํ ์ด๋ ๋ชจ๋ํฐ(conmon)์ ๋๋ค. ์์ C ํ๋ก๊ทธ๋จ์ด ํ๋ ์ผ์ ์ปจํ ์ด๋์ ๊ธฐ๋ณธ ํ๋ก์ธ์ค๋ฅผ ๊ฐ์ํ๊ณ ์ปจํ ์ด๋๊ฐ ์ฃฝ์ผ๋ฉด ์ข ๋ฃ ์ฝ๋๋ฅผ ์ ์ฅํ๋ ๊ฒ์ ๋๋ค. ๋ํ ๋์ค์ ์ฒจ๋ถํ ์ ์๋๋ก ์ปจํ ์ด๋์ tty๋ฅผ ์ด์ด๋ก๋๋ค. ์ด๊ฒ์ podman์ด ๋ถ๋ฆฌ ๋ชจ๋(๋ฐฑ๊ทธ๋ผ์ด๋)์์ ์คํ๋๋๋ก ํ์ฌ podman์ ์ข ๋ฃํ ์ ์์ง๋ง conmon์ ๊ณ์ ์คํ๋ฉ๋๋ค. ๊ฐ ์ปจํ ์ด๋์๋ ๊ณ ์ ํ conmon ์ธ์คํด์ค๊ฐ ์์ต๋๋ค.
- podman pod create --name test
- podman pod ls (pod ์ปจํ ์ด๋ ๋ฆฌ์คํธ)
- podman pod rm test
- podman pod rm -fa (๊ฐ์ ๋ก(f) ๋ชจ๋ (a) ์ปจํ ์ด๋๋ฅผ ์ญ์ )
podman pod ์ ์ปจํ ์ด๋ ๋ฃ๋ ๋๊ฐ์ง ๋ฐฉ๋ฒ ์ฐธ๊ณ
- ์ฒซ๋ฒ์งธ ๋ฐฉ๋ฒ
// ๋จผ์ pod ๋ฅผ test ๋ผ๋ ์ด๋ฆ์ผ๋ก ์์ฑํ๋ค.
podman pod create --name test
//์์ฑ๋ pod ๋ฅผ ํ์ธ ํ๋ค.
// ps, ls, list ๋ ๋์ผํ๋ค.
podman ls
// --pod ์ต์
์ ๋ถ์ด๋ฉด pod ์ infra ์ปจํ
์ด๋๋ค๋ ๋์จ๋ค.
// ๋ชจ๋ ์ปจํ
์ด๋์ pod infra ์ปจํ
์ด๋
podman ps -a --pod
// pod ์ปจํ
์ด๋ ๋ง ๋ํ๋๋ค.
podman ps --pod
// ์ด์ ์๋ก์ด ์ปจํ
์ด๋๋ ๋ง๋ค๊ณ ์ด๊ฒ์ pod ์ ์ฐ๊ฒฐ ์ํจ๋ค.
// detach mode ๋ก ์ต์ alpine ์ปจํ
์ด๋๋ฅผ ์คํ์ํค๊ณ top ๋ช
๋ น์ด๋ฅผ ์คํ์์ผฐ๋ค. --pod ์ต์
์ผ๋ก test ๋ผ๋ ์ด๋ฆ์ pod ์ ์ฐ๊ฒฐ ์์ผฐ๋ค.
podman run -dt --pod test docker.io/library/alpine:latest top
- ๋๋ฒ์งธ ๋ฐฉ๋ฒ
- ์๋ ์ฝ๋์์ --pod new:myapp_pod ๋ฅผ ๋ณด๋ฉด ์๋ก์ด pod ๋ฅผ myapp_pod ๋ผ๊ณ ์ง์ด์ฃผ์๋ค.
- The use of new: indicates to Podman that we want to create a new pod rather than attempt to assign the container to an existing pod.
podman run -d --restart=always --pod new:myapp_pod \
-e MYSQL_ROOT_PASSWORD="myrootpass" \
-e MYSQL_DATABASE="wp-db" \
-e MYSQL_USER="wp-user" \
-e MYSQL_PASSWORD="w0rdpr3ss" \
--name=wptest-db docker.io/mariadb
- https://github.com/containers/podman/blob/d3903a85910979d8212028cf814574047015db58/libpod/runtime_pod.go
- "github.com/containers/podman/v4/pkg/bindings/pods"
- https://github.com/containers/podman/search?q=NewPod
- github.com/containers/podman/v4/libpod -> libpod.Runtime.NewPod
- https://github.com/containers/podman/blob/c3d871a3f6cc7a94c5e86782ba63e05cd1d2faeb/pkg/specgen/generate/pod_create.go
๋จผ์ , specgen.NewSpecGenerator ํจ์๋ฅผ ํตํด์ SpecGenerator ์ ํด์ค๋ค. ์ด SpecGenerator ์ ์ ์ฅ๋ ์ ๋ณด๋ฅผ ํตํด์ ์ปจํ ์ด๋๋ฅผ ์์ฑํด์ค๋ค.
์ปจํ ์ด๋ ์์ฑ์ containers.CreateWithSpec ํจ์๊ฐ ๋ด๋นํ๋ค. ์ดํ์ podman ์ฌ์ฉ์ ๋ช ๋ น์ด์ binding api๋ ๊ฑฐ์ ๋งค์นญ์ด ๋๊ณ Restful Api ์ด๋ค.
์๋ฅผ ๋ค์ด์ ์ปจํ ์ด๋ ์์ฑํ ์ปจํ ์ด๋๊ฐ ์กด์ฌํ ๊ฒฝ์ฐ๋ podman start (์ปจํ ์ด๋ ID or ์ปจํ ์ด๋ Name) ์ binding api start ์ ๋์ผํ๋ค.
- Image string ์ปจํ ์ด๋๋ก ์ฌ์ฉํ ์ด๋ฏธ์ง
- Rootfs string rootfs๋ ๋ฃจํธ ํ์ผ ์์คํ ์ ๋ปํ๋ฉฐ, ๋ฆฌ๋ ์ค ํ์ผ ์์คํ ์ ๋ฏธ๋ฆฌ ํจํค์งํ ํด๋์ ๋ฐ์ด๋๋ฆฌ.
- Image ์ Rootfs ๋์คํ๋๋ ์ค์ ๋์ด ์์ด์ผ ํ๋ค.(๋น์ฐํ ์๋ฆฌ)
- ImageVolumeMode string image volume ์ ์ด๋ป๊ฒ ์์ฑํ ์ง๋ฅผ ๊ฒฐ์ ํ๋ค. optional ํ๋ฉฐ ์ค์ ์ ํ์ง ์๊ฑฐ๋ "anonymous" ๋ก ์ค์ ํ๋ฉด ์ต๋ช ์ผ๋ก ์ค์ ํ๋ค. (create as anonymous volumes).
- ๊ทธ์ธ "ignore" (do not create), "tmpfs" (create as tmpfs) ์ค์ ๊ฐ์ด ์กด์ฌํ๋ค.
- VolumesFrom []string ์ปจํ ์ด๋์ volume ์ ์์ค์ด๋ค. * volume ์ข๋ ํ์ ํด์ ๋ณด์ํ์.
- Init bool
Init์ ๋ฆฌ๋ ์ค ์ปค๋ ๋ถํ ์ด ์๋ฃ๋ ๋ค ์คํ๋๋ ์ฒซ ๋ฒ์งธ ํ๋ก์ธ์ค๋ค. ๋ํ ๋์์ Init์ ์ปค๋์ด ์ง์ ์คํํ๋ ์ ์ผํ ํ๋ก์ธ์ค๋ค.
๋ฐ๋ผ์ Init์ ๋ถ๋ชจ ํ๋ก์ธ์ค๋ฅผ ๊ฐ์ง์ง ์๋ ์ ์ผํ ํ๋ก์ธ์ค์ธ ๋์์, Init์ ์ ์ธํ ๋๋จธ์ง ๋ชจ๋ ํ๋ก์ธ์ค์ ์กฐ์์ด ๋๋ค.
docker ๊ธฐ์ค ์ค๋ช
docker run ์ํ ์ --init ์ต์ ์ด ์ฃผ์ด์ง์ง ์์ ๊ฒฝ์ฐ๋ container ๋ด์์ init process ๋ฅผ ๋ณ๋๋ก ๊ธฐ๋ํ์ง ์๋๋ค. docker run ์ํ ์ ๋๊ฒจ์ค command(/bin/bash)๊ฐ ๊ทธ๋๋ก 1 ๋ฒ process ๊ฐ ๋๋ค. ๋ฐ๋๋ก docker run ์ํ ์ --init ์ต์ ์ด ์ฃผ์ด์ง ๊ฒฝ์ฐ, init process ๋ฅผ container ๊ตฌ๋ ํ 1 ๋ฒ process ๋ก ๊ธฐ๋ํ๊ฒ ๋๋ค.
container ๋ด์์ init process ๋ฅผ 1 ๋ฒ์ผ๋ก ๊ตฌ๋ํ๋ค๋ ๊ฒ์ ์ค์ํ ์๋ฏธ๊ฐ ์๋ค. ์ด๋ child process ๋ฅผ ๋ฐ์์ฃผ์ด resource ์ ๋์๋ zombie process ์ ์์ฑ ๋ฑ์ ๋ฐฉ์งํ๋ init system ์ ์ญํ ์ container ๋ด์์ ์ํํ๋ค๋ ๋ป์ด๊ธฐ ๋๋ฌธ์ด๋ค.
init process ๋ก ์ฌ์ฉ๋๋ default binary ๋ /bin/docker-init ์ ์ฌ์ฉํ๋ค. (์ ํํ๊ฒ๋ which docker-init ์ ๊ฒฐ๊ณผ๋ก ์ฐพ์์ง๋ binary ๋ฅผ ์ฌ์ฉ) docker-init ์ container ์ธ๋ถ์์ ๋ณ๋๋ก ๊ธฐ๋๋๊ฑฐ๋ ํ๋ process ๊ฐ ์๋๋ค.
container ๋ด์์ ์ฒซ ๋ฒ์งธ๋ก ๊ธฐ๋๋์ด ๋ง์น Host ์์์ init process ์ฒ๋ผ ๋์ํ๋๋ก ๋ง๋ค์ด์ง ํ๋ก๊ทธ๋จ์ด๋ผ๊ณ ์๊ฐํ๋ฉด ๋๋ค.
- InitPath string ์์ Init ์ด true ์ด๋ฉด ์ค์ ํด์ค์ผ ํ๋ฉฐ Init ๋ฐ์ด๋๋ฆฌ์ ์์น๊ฐ ๊ธฐ๋ก๋๋ค. If not specified, the default set in the Libpod config will be used.
- Mounts []spec.Mount ์ปจํ ์ด๋์ ์ถ๊ฐํ ๋ง์ดํธ๋ค??? Image Volumes ๊ณผ VolumesFrom volumes ์ด ์ถฉ๋ํ ๋ ๋์ฒดํ๋ค.???
spec.Mount ๋ https://github.com/opencontainers/runtime-spec ์ ์ ์ ๋์ด ์๊ณ ์๋ ์ฝ๋๋ https://github.com/opencontainers/runtime-spec/tree/main/specs-go ์์์ config.go ์ ์ค์ ๋์ด ์๋ค.
// Mount specifies a mount for a container.
type Mount struct {
// Destination is the absolute path where the mount will be placed in the container.
Destination string `json:"destination"`
// Type specifies the mount kind.
Type string `json:"type,omitempty" platform:"linux,solaris"`
// Source specifies the source path of the mount.
Source string `json:"source,omitempty"`
// Options are fstab style mount options.
Options []string `json:"options,omitempty"`
}
- Volumes []*NamedVolume
named volum์ Docker(Linux์์๋ /var/lib/docker/volume/)๊ฐ ๊ด๋ฆฌํ๋ Host File System์ ์ผ๋ถ์ Data๊ฐ ์ ์ฅ๋๋ค.
/specgen/volumes.go ์ ์์.
// NamedVolume holds information about a named volume that will be mounted into
// the container.
type NamedVolume struct {
// Name is the name of the named volume to be mounted. May be empty.
// If empty, a new named volume with a pseudorandomly generated name
// will be mounted at the given destination.
Name string
// Destination to mount the named volume within the container. Must be
// an absolute path. Path will be created if it does not exist.
Dest string
// Options are options that the named volume will be mounted with.
Options []string
}
-
OverlayVolumes []*OverlayVolume ์ฐธ๊ณ - ์์ ์ docker ํ ๋ ๋ฌธ์ ๊ฐ ์์ด์ ์๋ฃ ์กฐ์ฌ ํ์๋๋ฐ ์์ด๋ฒ๋ฆผ.
-
// Image volumes bind-mount a container-image mount into the container.
-
// Optional.
-
ImageVolumes []*ImageVolume
json:"image_volumes,omitempty"
์์์ Mounts []spec.Mount ๊ฐ ๋์ ํ ์ ์๋ค๊ณ ํ๋ค.
// Devices are devices that will be added to the container.
// Optional.
Devices []spec.LinuxDevice `json:"devices,omitempty"`
// DeviceCGroupRule are device cgroup rules that allow containers
// to use additional types of devices.
DeviceCGroupRule []spec.LinuxDeviceCgroup `json:"device_cgroup_rule,omitempty"`
// IpcNS is the container's IPC namespace.
// Default is private.
// Conflicts with ShmSize if not set to private.
// Mandatory.
IpcNS Namespace `json:"ipcns,omitempty"`
// ShmSize is the size of the tmpfs to mount in at /dev/shm, in bytes.
// Conflicts with ShmSize if IpcNS is not private.
// Optional.
ShmSize *int64 `json:"shm_size,omitempty"`
- directory ์ค์
// WorkDir is the container's working directory.
// If unset, the default, /, will be used.
// Optional.
WorkDir string `json:"work_dir,omitempty"`
// Create the working directory if it doesn't exist.
// If unset, it doesn't create it.
// Optional.
CreateWorkingDir bool `json:"create_working_dir,omitempty"`
- ๋๋จธ์ง๋ ๊ทธ๋ฅ ์ด๋ ๊ฒ ๋ฃ๋๋ค.
// RootfsPropagation is the rootfs propagation mode for the container.
// If not set, the default of rslave will be used.
// Optional.
RootfsPropagation string `json:"rootfs_propagation,omitempty"`
// Secrets are the secrets that will be added to the container
// Optional.
Secrets []Secret `json:"secrets,omitempty"`
// Volatile specifies whether the container storage can be optimized
// at the cost of not syncing all the dirty files in memory.
Volatile bool `json:"volatile,omitempty"`
-
Name string ์ปจํ ์ด๋ ์ด๋ฆ, ์ธํ ์๋๋ฉด ๋๋คํ๊ฒ ์ธํ ๋จ.
-
Pod string Pod is the ID of the pod the container will join. ์ฐธ๊ณ 1 ์ฐธ๊ณ 2
-
Entrypoint []string // Entrypoint is the container's entrypoint. If not given and Image is specified, this will be populated by the image's configuration.
-
Command []string // Command is the container's command. If not given and Image is specified, this will be populated by the image's configuration.
-
EnvHost bool ํธ์คํธ์ env (ํ๊ฒฝ)์ด ์ปจํ ์ด๋์ ์ถ๊ฐ๋ ์ง ๊ฒฐ์ .
-
HTTPProxy bool // EnvHTTPProxy indicates that the http host proxy environment variables should be added to container.
-
Env map[string]string // Env is a set of environment variables that will be set in the container.
-
Terminal bool // Terminal is whether the container will create a PTY. PTY ๋ ์๊ฒฉ์ ์์ ์๋ฏธํ๋ค. ์ฐธ๊ณ 3, TTY, PTY, PTS
-
Stdin bool // Stdin is whether the container will keep its STDIN open. ์ต์ ๊ฐ์ธ๋ฐ, default ๊ฐ์ด ๋ฌด์์ธ์ง, ๊ทธ๋ฆฌ๊ณ stdin ์ด ์ปจํ ์ด๋์์ open ์ด ๋๋ฉด ์ด๋ค์ง ํ ์คํธ ํ ๊ฒ.
-
Labels map[string]string //Labels are key-value pairs that are used to add metadata to containers.
-
Annotations map[string]string // Annotations are key-value options passed into the container runtime that can be used to trigger special behavior. ์์ ์ฐพ์๋ณด์.
-
StopSignal *syscall.Signal // StopSignal is the signal that will be used to stop the container. Must be a non-zero integer below SIGRTMAX. If not provided, the default, SIGTERM, will be used. Will conflict with Systemd if Systemd is set to "true" or "always".
-
StopTimeout *uint // StopTimeout is a timeout between the container's stop signal being sent and SIGKILL being sent. If not provided, the default will be used. If 0 is used, stop signal will not be sent, and SIGKILL will be sent instead.
-
Timeout uint //// Timeout is a maximum time in seconds the container will run before main process is sent SIGKILL. If 0 is used, signal will not be sent. Container can run indefinitely
-
LogConfiguration *LogConfig // LogConfiguration describes the logging for a container including driver, path, and options. ์ด๊ฑด ํ ์คํธ ํด๋ณด์ผ ํ ๋ฏ. ๊ด๋ จ ์์ ์ฐพ์.
-
ConmonPidFile string // ConmonPidFile is a path at which a PID file for Conmon will be placed. If not given, a default location will be used.
-
์ฐธ๊ณ 5, Conmon, An OCI container runtime monitor. ์ดํด๋ณด์.
-
RawImageName string // RawImageName is the user-specified and unprocessed input referring to a local or a remote image. ์ดํด๋ณด์. ์๋ฃ์กฐ์ฌ ํ์
-
RestartPolicy string // RestartRetries is the number of attempts that will be made to restart the container. Only available when RestartPolicy is set to "on-failure".
-
RestartRetries *uint // RestartRetries is the number of attempts that will be made to restart the container. Only available when RestartPolicy is set to "on-failure".
-
OCIRuntime string // OCIRuntime is the name of the OCI runtime that will be used to create the container. If not specified, the default will be used.
-
Systemd string // Systemd is whether the container will be started in systemd mode. Valid options are "true", "false", and "always". "true" enables this mode only if the binary run in the container is /sbin/init or systemd. "always" unconditionally enables systemd mode.
-
"false" unconditionally disables systemd mode. If enabled, mounts and stop signal will be modified. If set to "always" or set to "true" and conditionally triggered, conflicts with StopSignal. If not specified, "false" will be assumed.
-
๋๋จธ์ง๋ ์ฝ๋๋ก ๋์ฒดํจ.
// Determine how to handle the NOTIFY_SOCKET - do we participate or pass it through
// "container" - let the OCI runtime deal with it, advertise conmon's MAINPID
// "conmon-only" - advertise conmon's MAINPID, send READY when started, don't pass to OCI
// "ignore" - unset NOTIFY_SOCKET
SdNotifyMode string `json:"sdnotifyMode,omitempty"`
// Namespace is the libpod namespace the container will be placed in.
// Optional.
Namespace string `json:"namespace,omitempty"`
// PidNS is the container's PID namespace.
// It defaults to private.
// Mandatory.
PidNS Namespace `json:"pidns,omitempty"`
// UtsNS is the container's UTS namespace.
// It defaults to private.
// Must be set to Private to set Hostname.
// Mandatory.
UtsNS Namespace `json:"utsns,omitempty"`
// Hostname is the container's hostname. If not set, the hostname will
// not be modified (if UtsNS is not private) or will be set to the
// container ID (if UtsNS is private).
// Conflicts with UtsNS if UtsNS is not set to private.
// Optional.
Hostname string `json:"hostname,omitempty"`
// Sysctl sets kernel parameters for the container
Sysctl map[string]string `json:"sysctl,omitempty"`
// Remove indicates if the container should be removed once it has been started
// and exits
Remove bool `json:"remove,omitempty"`
// ContainerCreateCommand is the command that was used to create this
// container.
// This will be shown in the output of Inspect() on the container, and
// may also be used by some tools that wish to recreate the container
// (e.g. `podman generate systemd --new`).
// Optional.
ContainerCreateCommand []string `json:"containerCreateCommand,omitempty"`
// PreserveFDs is a number of additional file descriptors (in addition
// to 0, 1, 2) that will be passed to the executed process. The total FDs
// passed will be 3 + PreserveFDs.
// set tags as `json:"-"` for not supported remote
// Optional.
PreserveFDs uint `json:"-"`
// Timezone is the timezone inside the container.
// Local means it has the same timezone as the host machine
// Optional.
Timezone string `json:"timezone,omitempty"`
// DependencyContainers is an array of containers this container
// depends on. Dependency containers must be started before this
// container. Dependencies can be specified by name or full/partial ID.
// Optional.
DependencyContainers []string `json:"dependencyContainers,omitempty"`
// PidFile is the file that saves container process id.
// set tags as `json:"-"` for not supported remote
// Optional.
PidFile string `json:"-"`
// EnvSecrets are secrets that will be set as environment variables
// Optional.
EnvSecrets map[string]string `json:"secret_env,omitempty"`
// InitContainerType describes if this container is an init container
// and if so, what type: always or once
InitContainerType string `json:"init_container_type"`
// Personality allows users to configure different execution domains.
// Execution domains tell Linux how to map signal numbers into signal actions.
// The execution domain system allows Linux to provide limited support
// for binaries compiled under other UNIX-like operating systems.
Personality *spec.LinuxPersonality `json:"personality,omitempty"`
- ๋ช๋ฒ ์ด์๋์ ์ด ์๋๋ฐ ์ค์๋๋ ๋ฎ์ผ๋, ์ ์ฌ์ฉํ ๋ ค๋ฉด ์ดํด๋์.
// ContainerSecurityConfig is a container's security features, including
// SELinux, Apparmor, and Seccomp.
type ContainerSecurityConfig struct {
// Privileged is whether the container is privileged.
// Privileged does the following:
// - Adds all devices on the system to the container.
// - Adds all capabilities to the container.
// - Disables Seccomp, SELinux, and Apparmor confinement.
// (Though SELinux can be manually re-enabled).
// TODO: this conflicts with things.
// TODO: this does more.
Privileged bool `json:"privileged,omitempty"`
// User is the user the container will be run as.
// Can be given as a UID or a username; if a username, it will be
// resolved within the container, using the container's /etc/passwd.
// If unset, the container will be run as root.
// Optional.
User string `json:"user,omitempty"`
// Groups are a list of supplemental groups the container's user will
// be granted access to.
// Optional.
Groups []string `json:"groups,omitempty"`
// CapAdd are capabilities which will be added to the container.
// Conflicts with Privileged.
// Optional.
CapAdd []string `json:"cap_add,omitempty"`
// CapDrop are capabilities which will be removed from the container.
// Conflicts with Privileged.
// Optional.
CapDrop []string `json:"cap_drop,omitempty"`
// SelinuxProcessLabel is the process label the container will use.
// If SELinux is enabled and this is not specified, a label will be
// automatically generated if not specified.
// Optional.
SelinuxOpts []string `json:"selinux_opts,omitempty"`
// ApparmorProfile is the name of the Apparmor profile the container
// will use.
// Optional.
ApparmorProfile string `json:"apparmor_profile,omitempty"`
// SeccompPolicy determines which seccomp profile gets applied
// the container. valid values: empty,default,image
SeccompPolicy string `json:"seccomp_policy,omitempty"`
// SeccompProfilePath is the path to a JSON file containing the
// container's Seccomp profile.
// If not specified, no Seccomp profile will be used.
// Optional.
SeccompProfilePath string `json:"seccomp_profile_path,omitempty"`
// NoNewPrivileges is whether the container will set the no new
// privileges flag on create, which disables gaining additional
// privileges (e.g. via setuid) in the container.
NoNewPrivileges bool `json:"no_new_privileges,omitempty"`
// UserNS is the container's user namespace.
// It defaults to host, indicating that no user namespace will be
// created.
// If set to private, IDMappings must be set.
// Mandatory.
UserNS Namespace `json:"userns,omitempty"`
// IDMappings are UID and GID mappings that will be used by user
// namespaces.
// Required if UserNS is private.
IDMappings *types.IDMappingOptions `json:"idmappings,omitempty"`
// ReadOnlyFilesystem indicates that everything will be mounted
// as read-only
ReadOnlyFilesystem bool `json:"read_only_filesystem,omitempty"`
// Umask is the umask the init process of the container will be run with.
Umask string `json:"umask,omitempty"`
// ProcOpts are the options used for the proc mount.
ProcOpts []string `json:"procfs_opts,omitempty"`
// Mask is the path we want to mask in the container. This masks the paths
// given in addition to the default list.
// Optional
Mask []string `json:"mask,omitempty"`
// Unmask is the path we want to unmask in the container. To override
// all the default paths that are masked, set unmask=ALL.
Unmask []string `json:"unmask,omitempty"`
}
- ์ผ๋จ ์๋ต
- ์ผ๋จ ์๋ต
- ์๋ ์ฝ๋๋ก ๋์ ํ๋๋ฐ, ์ผ๋จ ์ปจํ ์ด๋ ์ก์ ๊ตฌ์ฑํ ๋ Resource ์ ๋ํ ์ ํ์ ๋ฌ์ผ ํ๊ธฐ ๋๋ฌธ์ ์ค์ ๋ก ์ ์ดํด๋ด์ผ ํ๋ค.
// ContainerResourceConfig contains information on container resource limits.
type ContainerResourceConfig struct {
// ResourceLimits are resource limits to apply to the container.,
// Can only be set as root on cgroups v1 systems, but can be set as
// rootless as well for cgroups v2.
// Optional.
ResourceLimits *spec.LinuxResources `json:"resource_limits,omitempty"`
// Rlimits are POSIX rlimits to apply to the container.
// Optional.
Rlimits []spec.POSIXRlimit `json:"r_limits,omitempty"`
// OOMScoreAdj adjusts the score used by the OOM killer to determine
// processes to kill for the container's process.
// Optional.
OOMScoreAdj *int `json:"oom_score_adj,omitempty"`
// Weight per cgroup per device, can override BlkioWeight
WeightDevice map[string]spec.LinuxWeightDevice `json:"weightDevice,omitempty"`
// IO read rate limit per cgroup per device, bytes per second
ThrottleReadBpsDevice map[string]spec.LinuxThrottleDevice `json:"throttleReadBpsDevice,omitempty"`
// IO write rate limit per cgroup per device, bytes per second
ThrottleWriteBpsDevice map[string]spec.LinuxThrottleDevice `json:"throttleWriteBpsDevice,omitempty"`
// IO read rate limit per cgroup per device, IO per second
ThrottleReadIOPSDevice map[string]spec.LinuxThrottleDevice `json:"throttleReadIOPSDevice,omitempty"`
// IO write rate limit per cgroup per device, IO per second
ThrottleWriteIOPSDevice map[string]spec.LinuxThrottleDevice `json:"throttleWriteIOPSDevice,omitempty"`
// CgroupConf are key-value options passed into the container runtime
// that are used to configure cgroup v2.
// Optional.
CgroupConf map[string]string `json:"unified,omitempty"`
// CPU period of the cpuset, determined by --cpus
CPUPeriod uint64 `json:"cpu_period,omitempty"`
// CPU quota of the cpuset, determined by --cpus
CPUQuota int64 `json:"cpu_quota,omitempty"`
}
- ๊ด๋ จ ์์๋ฅผ ์ฐพ์๋ณด์.
// ContainerHealthCheckConfig describes a container healthcheck with attributes
// like command, retries, interval, start period, and timeout.
type ContainerHealthCheckConfig struct {
HealthConfig *manifest.Schema2HealthConfig `json:"healthconfig,omitempty"`
}
tts/pts ์ฐธ๊ณ
https://eehoeskrap.tistory.com/245 https://minholee93.tistory.com/entry/Linux-Process-Status-PS ํ๋ก์ธ์ค ์ธ์ ๋ฆฌ๋ ์ ํ๋ก์ธ์ค ๊ทธ๋ฃน ๋ฆฌ๋ https://blueyikim.tistory.com/89
PROCESS STATE CODES Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process:
D uninterruptible sleep (usually IO)
R running or runnable (on run queue)
S interruptible sleep (waiting for an event to complete)
T stopped by job control signal
t stopped by debugger during the tracing
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z defunct ("zombie") process, terminated but not reaped by
its parent
For BSD formats and when the stat keyword is used, additional
characters may be displayed:
< high-priority (not nice to other users)
N low-priority (nice to other users)
L has pages locked into memory (for real-time and custom IO)
s is a session leader
l is multi-threaded (using CLONE_THREAD, like NPTL pthreads
do)
+ is in the foreground process group
๊ผญ ์ฝ์ด๋ณด๊ธฐ(์ ๋ฆฌ์ ) https://mkdev.me/posts/the-tool-that-really-runs-your-containers-deep-dive-into-runc-and-oci-specifications
https://chhanz.github.io/container/2020/09/22/podman-build-flask-example-app/
๋ค์์คํ์ด์ค https://linuxtut.com/en/61f1291f6ee804531328/ https://www.44bits.io/ko/keyword/linux-namespace
๊ธฐ์ด https://docs.oracle.com/en/learn/storage_podman_containers/#introduction https://phoenixnap.com/kb/podman-tutorial
containerfile https://meta.stackoverflow.com/questions/407966/generalize-dockerfile-to-containerfile-for-now-and-the-future https://www.mankier.com/5/Containerfile
alpine https://blog.naver.com/PostView.nhn?blogId=ki630808&logNo=222149370156
cmd vs entrypoint https://bluese05.tistory.com/77