Why are containers created via Portainer exiting after starting and those created via docker command line stable

Hello all,

Im playing around with Docker and Portainer, and I have this observation, just wanted to clarify:

– when I create / pull an image and run it with command like: sudo docker run -it --name ubuntuserver3 ubuntu /bin/bash, the container runs and seems stable.

By ‘stable’, I mean if I look at my list of containers in Portainer, these ontainers created via docker command line are running for like 20-30mins+. I can detach from it and its still running, etc.

– when I use Portainer to create a container, etc; it gets created but exits suddenly, and even after restarting and restarting it again, it exits.

what could be the issue here? why are containers created with Portainer suddenly exiting by themselves. Portainer and docker are on the same machine.

Pls help to clarify / resolve
regards
1960web

Why it works with docker run is simple: it is because of the t in -it. It sets the tty to true, which keeps the container running, even though the process you start is not a background process. Without the t, the container would not be kept running.

The absence of tty=true is the reason, why the same container terminates after starting /bin/bash in the foreground, which then ends, because it does not run a permanent running process. When the process ends, the container stops.

Requiring tty=true is usually an indicator that you do something that would be considered a bad habit.

@meyay
Thanks for the clarification. Wow, didn’t know that.
I actually thought there was some problem with my installation.

Question: how should I add the tty=true option to a container created in Portainer? and considering the container is created and running already.

regards
1960web

I try to stay away from ClickOps as much as possible → I don’t use Portainer.

Though, generally containers are supposed to be ephemeral by design. So the normal approach would be to remove an existing container, and re-create a container using the desired parameters.