LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Containers (https://www.linuxquestions.org/questions/linux-containers-122/)
-   -   Trouble stopping a Podman container when using Bash as the entrypoint (https://www.linuxquestions.org/questions/linux-containers-122/trouble-stopping-a-podman-container-when-using-bash-as-the-entrypoint-4175725493/)

Mermohn 05-29-2023 03:57 AM

Trouble stopping a Podman container when using Bash as the entrypoint
 
Hello,

I'm new to Podman, and I'm trying to create an image. Everything works fine, except gracefully stopping the container when I'm done with it. The image is based on Debian, and I want the entrypoint to be the Bash shell. If I attach to the container and then use the exit command when I'm done with it, the shell exits and the container stops. However, if I try to just stop the container using "podman stop", the shell does not exit, and Podman eventually kills it.

I don't have any issue with attaching to the shell and exiting each time, but this problem does tell me that I'm doing something incorrectly, and I'd like to figure out what it is. This is the relevant portion of my Dockerfile:
ENTRYPOINT ["/bin/bash"]
CMD ["--login"]

I've also tried using Tini, as suggested by ChatGPT:
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["/bin/bash", "--login"]

Neither of these solutions work. I assume that Bash just doesn't respond to the stop signal properly. I was hoping someone here might know of a way that I can resolve this. I like having Bash as my entrypoint, because my image needs to do a few different things, and I'd rather not be limited to one specific function as the entrypoint.


Thanks.

pan64 05-30-2023 05:59 AM

Quote:

Originally Posted by Mermohn (Post 6433452)
Hello,

I'm new to Podman, and I'm trying to create an image. Everything works fine, except gracefully stopping the container when I'm done with it. The image is based on Debian, and I want the entrypoint to be the Bash shell. If I attach to the container and then use the exit command when I'm done with it, the shell exits and the container stops. However, if I try to just stop the container using "podman stop", the shell does not exit, and Podman eventually kills it.

Yes, if you don't exit podman will kill it. That is the way how does it work. podman cannot exit your shell instead of you.


All times are GMT -5. The time now is 07:00 AM.