Hello everyone,
I've urgent question about containers, how i make my configurations permanent and survive reboot?
starting from creating containers and being in running state and everything.
Thanks
@khokha This article should help you https://www.redhat.com/sysadmin/container-systemd-persist-reboot
@khokha This article should help you https://www.redhat.com/sysadmin/container-systemd-persist-reboot
Hello @khokha !
Making your container configurations permanent and survive reboot can be achieved via several procedures , some of them ( but not limited to ) are as follows :
1. Use persistent volume : A persistent volume is a block of storage that is not tied to any particular container. This means that if you create a container that uses a persistent volume, the data in that container will survive even if the container is stopped or restarted.
2. Mount the data or configuration files : use the -v or --volume flag when running the podman run command. This will avoid the hard coding of your configuration files inside your container , because you can change it externally and mount it using -v. This will persist after rboot also.
3. Environment variables : use -e while running podman run command to pass environment variables : eg. -e MYSQL_USERNAME -e MYSQL_PASSWORD etc.
4. Ansible : using it define your desired state and it will automatically apply when the container starts.
5. Integrating Podman with systemd : This allows for setting up containers or pods as systemd services. This works like creating a basic user as a "service user" for the application with systemd , then, the user is given the ability to start a service at system start that persists even after the last user session closes. Use the loginctl command to configure the systemd user service to persist after the last user session of the configured service closes.
what is the difference between the persistent volume and the mount data? aren't they the same we use -v option to data persistent?
Persistent volume is a block of storage that is not tied to any particular container i.e data in that container will survive even if the container is stopped or restarted.
Mount data using the -v option allows you to bind directories between the host machine and the container, making data available and persistent. It allows you to mount data volumes or directories from the host machine into the container.
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.