Open Adelcelevator opened 1 year ago
@mheon PTAL
The problem is that podman thinks you rebooted since systemd will clean up all tmpfs files under /run/user/$UID
when you close your session. However the locks are stored in /dev/shm/libpod_rootless_lock_$UID
which is not removed, so when you log in again podman thinks the locks in that file are already taken and errors out.
As a workaround it should be enough to remove that file but make sure to only do this before you run any podman commands.
This is usually why we recommend loginctl enable-linger
for users running Podman processes - avoiding systemd session cleanup avoids the problem entirely.
I suppose we could make the refresh logic auto-remove the shared-memory locks to force recreation, but I feel like we're just scratching the surface of the problems here. Detecting a reboot when one did not occur seems ripe to cause issues with lingering files and state that we don't expect.
Could we move the lock shm file into a "normal" file on tmpfs (runroot) instead?
I run into issues like this several times while playing around with different --root/--runroot for testing, they all end up sharing the same lock file which feels wrong?
I don't think there is a difference other than calling regular open()
vs shm_open()
assuming the file we open is actually on a tmpfs.
What we're doing now is more POSIX-compatible than that, AFAIK, so this might matter for FreeBSD? Otherwise, I don't see a reason why we couldn't do this.
Hi @Luap99, I execute podman system reset
, in theory it will solve the problem but it persist when I create new containers, When I logout, after the creation of the containers, and I login again, the same problem have been printed when I execute podman ps -a
A friendly reminder that this issue had no activity for 30 days.
A friendly reminder that this issue had no activity for 30 days.
This issue interests me also. I'm running into a comparable error.
@mheon what should we do with this one?
Moving the SHM file seems reasonable, but low-priority.
Hello, a solution I found is to use loginctl enable-linger [users owner of containers]
, with this the containers still working when user logout of the ssh session, idk if this is a solution but it works.
@Adelcelevator This workaround would not work after a system reboot. Though, the issue is not too much of a problem as the errors happen only once on a fresh bootup.
pavin@lmde:~$ distrobox ls
ERRO[0000] Refreshing container 7d553e20b5af16e6252d3ed1d90e5b58ffa200cfc916d50fb695e6b9b1ee6122: acquiring lock 0 for container 7d553e20b5af16e6252d3ed1d90e5b58ffa200cfc916d50fb695e6b9b1ee6122: file exists
ERRO[0000] Refreshing volume 8a7bd54137e2dd29e2cf6a5ec7a1d478e448dd43260490acffd1599b9c622141: acquiring lock 1 for volume 8a7bd54137e2dd29e2cf6a5ec7a1d478e448dd43260490acffd1599b9c622141: file exists
ERRO[0000] Refreshing volume 976730261e76505f7652bb39439e6d874fa882c0aaba126341dfd41c2a15910a: acquiring lock 2 for volume 976730261e76505f7652bb39439e6d874fa882c0aaba126341dfd41c2a15910a: file exists
ID | NAME | STATUS | IMAGE
6f6dee40f25a | deb | Exited (143) 2 hours ago | quay.io/toolbx-images/debian-toolbox:12
c4e379d3e153 | deb-unprocess | Exited (137) 2 days ago | quay.io/toolbx-images/debian-toolbox:12
fd6944ece16c | deb-unipc | Exited (143) 2 days ago | quay.io/toolbx-images/debian-toolbox:12
e72fb6b8ff75 | deb-unnet | Exited (143) 2 days ago | quay.io/toolbx-images/debian-toolbox:12
395ae2277973 | deb-undevsys | Exited (143) 2 days ago | quay.io/toolbx-images/debian-toolbox:12
dba6d239a775 | deb-unall | Exited (137) 31 hours ago | quay.io/toolbx-images/debian-toolbox:12
a8bbab296e02 | deb-init | Exited (130) 2 hours ago | quay.io/toolbx-images/debian-toolbox:12
7d553e20b5af | arch-init | Exited (130) 2 hours ago | quay.io/toolbx-images/archlinux-toolbox:latest
*I have proven solution for this .
Version: podman version 4.2.0
once we close session podman also closed
.
systemd
is managing the boot process and system task management.
copy podman systemd file into systemd configuration.
cp /usr/lib/systemd/system/podman.service /etc/systemd/system/
Modify file, with service to listen on 8080 port with time arg=0, which indicated the service runs indefinately until it is stopped.
cat /etc/systemd/system/podman.service
[Unit]
Description=Podman Api Service
Requires=podman.socket
After=podman.socket
Documentation=man:podman-system-service(1)
StartLimitIntervalSec=0
[Service]
Type=exec
KillMode=process
Envionment=LOGGING=-"--log-level=info"
ExecStart=/usr/bin/podman $LOGGING system service tcp:0.0.0.0:8080 --time=0
tcp:0.0.0.0:8080
wiith tcp:127.0.0.1:8080
Restart podman socket and service.
systemctl daemon-reload
systemctl enable podman.socket podman
systemctl start podman.socket podman
This is what worked for me
PS. i think it only works for users running a rootless Podman container (i.e., a container that's run by a non-root user).
You want the container to keep running even after the user has logged out, you will need to enable lingering for that user. This is because rootless Podman containers are tied to the user session, and they will be stopped when the user logs out unless lingering is enabled
You can enable lingering for a user with the loginctl
command. This allows the user's processes to continue running after the user has logged out.
Here's how you can do it:
sudo loginctl enable-linger username
Replace username
with the name of the user for whom you want to enable lingering.
This command will create a file named after the user in the /var/lib/systemd/linger/
directory. This file signals to systemd that lingering is enabled for the user.
After you've enabled lingering, the user's processes will continue to run after the user has logged out, until they are explicitly stopped or the system is rebooted.
BUT IF YOU ARE RUNNING A ROOT PODMAN CONTAINER , YOU CAN USE A SYSTEMD USER SERVICE
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
This bug is an old know, I try to fix it like the other people resolve, but it still persist, When I login via ssh, I start some containers and use it, before I close the session that conteiners are still up, but when I logout, or close the session, or lose the ssh session, the conteiners go down automaticly and when I enter to the server again and put the podman ps command I found the next message in the top of the output:
ERRO[0000] Refreshing container <containerID>: error acquiring lock 0 for container <containerID>: file exists
Steps to reproduce the issue:
Access to the server via ssh.
Create a container with podman.
Be sure that you container is running.
Close your session, disconected from the server.
Login into the server server again via ssh and the container will be in Exited state and with the error message at the begin of the output of podman ps command.
Describe the results you received: Whe I do follow the previous steps I get the next output:
Describe the results you expected:
I expected to have my container running.
Additional information you deem important (e.g. issue happens only occasionally): Before I enable SELinux and reboot the system it was working fine, after I enable SELinux and reboot the system for an autorelabel it fall, and I was looking for alerts in SELinux and put SELinux in Permissive mode, it still persist with the problem.
Output of
podman version
:Output of
podman info
:Package info (e.g. output of
rpm -q podman
orapt list podman
orbrew info podman
):Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide?
Yes
Additional environment details (AWS, VirtualBox, physical, etc.):
Is over contabo provider.