Skip to content

Instantly share code, notes, and snippets.

@linuxmalaysia
Forked from ApOgEE/podman-survival.md
Last active December 16, 2023 20:26
Show Gist options
  • Save linuxmalaysia/11936ff5f50df22e767570350a89df6b to your computer and use it in GitHub Desktop.
Save linuxmalaysia/11936ff5f50df22e767570350a89df6b to your computer and use it in GitHub Desktop.
Buat Service Supaya Podman Survive Reboot

Podman Survive Reboot

Docker adalah service dalam server manakala podman pula bukan service. Perbezaan antara Docker dan Podman dalam situasi ini ialah apabila kita reboot server.

Bila kita guna Docker, semua container yang run sebelum reboot akan run balik bila kita reboot server dan service docker kembali running. Tapi ini tak berlaku bila kita guna podman sebab podman bukanlah service.

Oleh itu, kita kena jadikan podman sebagai service.

Caranya:

# generate service script
podman generate systemd --new --name [nama-container] > /etc/systemd/system/[nama-service].service

# reload systemd daemon
sudo systemctl daemon-reload

# check service script
systemctl list-unit-files | grep [nama-service]

# check status
systemctl status [nama-service]

# enable service
systemctl enable [nama-service]

# start service
systemctl start [nama-service]

# tengok podman kita tu dah run ke tak
podman ps

Lepas tu bolehlah reboot server dan tengok service podman tu akan up balik secara auto.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment