I start my docker container with a name. like this:
docker run --name regsvc my-registrationservice
If I call docker stop regsvc, the next time I run the above command it fails. I have to run these commands first.
docker kill regsvc
docker system prune
That seems excessive. Is there a better way to stop the container and restart it?
Thnx Matt
When you stop a container, you can still see it with:
Now the container is not alive but it is still there. So, you only need to restart it if you want it to work again:
The command docker run will create a container from your image. So if you want to use docker run again, you need firstly remove your container (after stop it):
I believe you want to run a new container every time you issue
docker run
and it would be better for you to use--rm
flag:This will remove the container when your container exits. This is better if you don't want to save data of container.
As suggested by @trong-lam-phan you could restart your existing container using