0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

podmanでUbuntu 24.04 に常駐のUbuntu 24.04 コンテナを置いてみるよ

0
Posted at

Geminiに聞きつつやったので新たにやる人も「そっちに聞けば?」みたいな気持ちにはなりますが……w

$ sudo apt install -y podman podman-compose

/etc/containers/registries.confにレジストリとしてdocker.ioを足します

unqualified-search-registries = ["docker.io"]

今回はDocker Hubのアカウントとか聞かれてませんが、最近pullの数とかの制約が厳しくなっているので要るケースもあるかもしれません

$ podman pull docker.io/library/ubuntu:24.04

今回は ~/pods/claw にコンテナへマウントするフォルダを用意しておきます

podman generate systemd --name claw-service --new --filesかなんかでファイルが作られました。なお、Quadlet使えって警告は出ます。ExecStartの欄で使うユーザやワーキングディレクトリの設定を足します。

~/.config/systemd/user/container-claw-service.service
[Unit]
Description=Podman container-claw-service.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=%t/containers

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=always
TimeoutStopSec=70
ExecStart=/usr/bin/podman run \
        --cidfile=%t/%n.ctr-id \
        --cgroups=no-conmon \
        --rm \
        --sdnotify=conmon \
        --replace \
        -d \
        --user ubuntu \
        --workdir /home/ubuntu \
        --userns keep-id:uid=1000,gid=1000 \
        --name claw-service \
        -v /home/omaenonamae/pods/claw:/home/ubuntu:Z \
        docker.io/library/ubuntu:24.04 sleep infinity
ExecStop=/usr/bin/podman stop \
        --ignore -t 10 \
        --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm \
        -f \
        --ignore -t 10 \
        --cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all

[Install]
WantedBy=default.target
$ systemctl --user daemon-reload
$ systemctl --user enable --now container-claw-service.service

何か試行錯誤するなら

$ systemctl --user daemon-reload
$ systemctl --user restart container-claw-service.service

再起動をまたいで勝手に起動してもらうために以下もします

$ sudo loginctl enable-linger $(whoami)

何に使うかはまぁ人に依りますが、私はクローカードの収集でもしようと思います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?