You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dear team,
along the possible values for containers.podman.podman_pod's state are startedandrestarted`. They somehow behave differently from what I expect. I would appreciate if you can take the time to review the following example and my question.
Example scenario
I have created a pod consisting of three containers.
]$ podman pod ps
POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS
3e0b4e78d226 nc_pod Running 6 minutes ago c141f6351cec 3
]$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c141f6351cec localhost/podman-pause:5.1.1-1717459200 6 minutes ago Up 6 minutes 127.0.0.1:40671->80/tcp 3e0b4e78d226-infra
d2284c00dec3 docker.io/library/mariadb:10.11.2 mariadbd 6 minutes ago Up 6 minutes 127.0.0.1:40671->80/tcp nc_mariadb
7d8b7285fda7 docker.io/library/nextcloud:25-apache apache2-foregroun... 6 minutes ago Up 6 minutes 127.0.0.1:40671->80/tcp nextcloud
]$ podman pod inspect -f '{{ .CreateCommand }}' nc_pod
[podman pod create --infra=True --infra-conmon-pidfile /tmp/nc_pod_infra.pid --publish 127.0.0.1:40671:80 --name nc_pod]
]$ podman inspect -f '{{ .Config.CreateCommand }}' nc_mariadb
[podman container run --name nc_mariadb --conmon-pidfile /tmp/mariadb_conmon.pid --pod nc_pod --env MYSQL_USER=<masked> --env MYSQL_PASSWORD=<masked> --env MYSQL_ROOT_PASSWORD=<masked> --env MYSQL_DATABASE=nc_db --volume mysql_data:/var/lib/mysql:Z --detach=True docker.io/library/mariadb:10.11.2]
]$ podman inspect -f '{{ .Config.CreateCommand }}' nextcloud
[podman container run --name nextcloud --conmon-pidfile /tmp/nc_conmon.pid --pod nc_pod --env MYSQL_DATABASE=nc_db --env MYSQL_USER=<masked> --env MYSQL_PASSWORD=<masked> --env MYSQL_HOST=127.0.0.1 --env NEXTCLOUD_ADMIN_USER=<masked> --env NEXTCLOUD_ADMIN_PASSWORD=<masked> --env NEXTCLOUD_TRUSTED_DOMAINS= --env SMTP_HOST=smtp.example.com --env SMTP_SECURE=tls --env SMTP_PORT=587 --env SMTP_AUTHTYPE=LOGIN --env SMTP_NAME=bob@example.com --env SMTP_PASSWORD=MailSecret1! --env MAIL_FROM_ADDRESS=no-reply --env MAIL_DOMAIN=example.com --env OVERWRITEPROTOCOL= --env OVERWRITECLIURL= --volume nc_html:/var/www/html:Z --volume nc_apps:/var/www/html/custom_apps:Z --volume nc_config:/var/www/html/config:Z --volume nc_data:/var/www/html/data:Z --detach=True docker.io/library/nextcloud:25-apache]
I'm able to stop and start the pod again with the following commands:
]$ podman pod stop nc_pod
3e0b4e78d22616e8d5617c9a27de0252f4d39658cf4a8761d7efc9629f435cde
]$ podman pod ps
POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS
3e0b4e78d226 nc_pod Exited 15 minutes ago c141f6351cec 3
]$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
]$ podman pod start nc_pod
3e0b4e78d22616e8d5617c9a27de0252f4d39658cf4a8761d7efc9629f435cde
]$ podman pod ps
POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS
3e0b4e78d226 nc_pod Running 16 minutes ago c141f6351cec 3
]$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c141f6351cec localhost/podman-pause:5.1.1-1717459200 16 minutes ago Up 11 seconds 127.0.0.1:40671->80/tcp 3e0b4e78d226-infra
d2284c00dec3 docker.io/library/mariadb:10.11.2 mariadbd 16 minutes ago Up 11 seconds 127.0.0.1:40671->80/tcp nc_mariadb
7d8b7285fda7 docker.io/library/nextcloud:25-apache apache2-foregroun... 16 minutes ago Up 11 seconds 127.0.0.1:40671->80/tcp nextcloud
So far, so good. Now I would like to do the same using a playbook.
Playbook 1 - state: restarted
---
- name: Stop and start pod
hosts: localhost
connection: local
tasks:
- name: Stop the pod
containers.podman.podman_pod:
name: nc_pod
state stopped
tags:
- stop
- never
- name: Start the pod
containers.podman.podman_pod:
name: nc_pod
state restarted
tags:
- start
- never
This works. Although I would have expected that a pod or container needs to be running to be able to be restarted. I'm wondering that a restart is possible from status Exited.
]$ ansible-playbook playbook_one.yml --tags stop,start
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost
does not match 'all'
PLAY Stop and start pod] *******************************
TASK [Gathering Facts] *********************************************************************************
ok: [localhost]
TASK [Stop the pod] **********************
changed: [localhost]
TASK [Start the pod] **********************************
changed: [localhost]
PLAY RECAP *********************************************************************************************
localhost : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
]$ podman pod ps
POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS
3e0b4e78d226 nc_pod Running 25 minutes ago c141f6351cec 3
Playbook 2 - state: started
Now I use the following playbook which I did expect to work as well but which failed:
---
- name: Stop and start pod
hosts: localhost
connection: local
tasks:
- name: Stop the pod
containers.podman.podman_pod:
name: nc_pod
state stopped
tags:
- stop
- never
- name: Start the pod
containers.podman.podman_pod:
name: nc_pod
state started
tags:
- start
- never
And here is what happens:
]$ ansible-playbook playbook_one.yml --tags stop,start
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost
does not match 'all'
PLAY [Backup or Restore Nextcloud with MariaDB in a rootless Podman Pod] *******************************
TASK [Gathering Facts] *********************************************************************************
ok: [localhost]
TASK [tronde.nextcloud.backup_restore_nextcloud : Stop nc_pod for offline backup] **********************
changed: [localhost]
TASK [tronde.nextcloud.backup_restore_nextcloud : Start nc_pod again] **********************************
changed: [localhost]
PLAY RECAP *********************************************************************************************
localhost : ok=3 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
]$ podman pod ps
POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS
8836d60999b1 nc_pod Running 18 seconds ago 44507b446d8c 1
]$ podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
44507b446d8c localhost/podman-pause:5.1.1-1717459200 37 seconds ago Up 38 seconds 8836d60999b1-infra
Questions
Why are two of my containers gone?
Can someone explain the different behavior of restarted and started to me?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Dear team,
along the possible values for
containers.podman.podman_pod's state are
startedand
restarted`. They somehow behave differently from what I expect. I would appreciate if you can take the time to review the following example and my question.Example scenario
I have created a pod consisting of three containers.
I'm able to stop and start the pod again with the following commands:
So far, so good. Now I would like to do the same using a playbook.
Playbook 1 - state: restarted
This works. Although I would have expected that a pod or container needs to be running to be able to be restarted. I'm wondering that a restart is possible from status Exited.
Playbook 2 - state: started
Now I use the following playbook which I did expect to work as well but which failed:
And here is what happens:
Questions
restarted
andstarted
to me?Cheers,
Joerg
Beta Was this translation helpful? Give feedback.
All reactions