I have put a script with an endless loop inside a Containerfile.
When I go inside the container and run that script in the background I can see that the process is running by doing a ps -ef.
But when I try to start the process inside the Containerfile it is not running, even though the podman build and podman run commands are without error.
I am using rootless podman.
This is my Containerfile:
$ cat Containerfile
FROM alpine
RUN apk update
RUN apk add vim
RUN apk add bash
COPY ./useless_process.sh /home
RUN bash /home/useless_process.sh &
# how to build:
# podman build . -t "manualpihimage"
# how to run:
# podman run -it --name "manualpihcontainer" manualpihimage
I have also tried using the CMD and the ENTRYPOINT commands but the process did not start.
The expectation was that the process would run in the background.
I have tried it with Containerfile as follows. Note that I removed the useless
&- makes no sense in the context of the container and usedCMDbecause we don't want to run it while building the image but when we start the container.I created useless_process.sh with:
Then
podman build . -t=image1andpodman run -d --name=container1 image1to start it detached.And we can see our useless process is running