I'm newbie in docker. I use below command to run the certbot image twice:

docker run --rm certbot/certbot

I'd like to stop it but I can't. This command has started to produce many containers and these containers are automatically closed and produced again.

I have done the following:

1.Remove and kill containers

docker rm -f $(docker ps -a -q)
docker kill $(docker ps -q)

2.Through the following command, I tried to get the ID process and kill it:

ps aux | grep <containerId> | awk '{print $1 $2}'


kill -9 <processId>  

But the ID process keeps changing.

3.I restarted Docker, even rebooted the whole server but still the problem persists.

I posted a screen record gif that shows that containers are constantly generated with different IDs and are automatically deleted.


How to resolve this problem?

Docker version 24.0.2, build cb74dfc
CentOS Linux release 7.9.2009 (Core)

2 Answers 2


I have created a swarm service, it will keep recreating the container everytime it fails, which is expected and The certbot service is constantly failing.

I disabled swarm mode with below command and re-initialized swarm again and my problem has been solved.

docker swarm leave --force
docker swarm init

I would check the logs and see if something is notable there first.

 # docker logs 459979a55425
    [2024-01-30 23:56:18 +0000] [1] [INFO] Starting gunicorn 21.2.0
    [2024-01-30 23:56:18 +0000] [1] [INFO] Listening at: (1)
    [2024-01-30 23:56:18 +0000] [1] [INFO] Using worker: sync

And try monitoring events while the container is active. This would need to be run in another terminal:

# docker events
2024-02-29T06:59:09.512867172-06:00 network connect ...(container=...b7fda34f83a, name=bridge, type=bridge)

The check if there is a restart policy for some reason (https://docs.docker.com/config/containers/start-containers-automatically/).

# docker inspect 413071a51305
           "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0

If restart is set to always or similar, you can change it with something like below. There is more in the link above:

docker update --restart=no 459979a55425

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.