user1097108
user1097108

Reputation: 355

How to have docker restart container with a completely new container?

It seems like the --restart option for docker run will try to restart the exact same container which has stopped. I would like it to restart with a completely new container, as if I had just run the 'docker run' command again. Is this currently possible?

Upvotes: 1

Views: 126

Answers (1)

Sanketh Katta
Sanketh Katta

Reputation: 6311

Think of a docker "container" as an instance of a docker "image". Once you've created that instance it will live on with its state. If you want a new container you'll need to create a new one with the same image with "docker run".

If you have lots of parameters passed in when you create your container, you might want to checkout using docker-compose for the behavior you want. That way you can create a docker-compose.yml file with all the parameters you use to create your container then run:

docker-compose up --force-recreate

This would manage creating the exact container you want each time.

Upvotes: 1

Related Questions