To stop one or more running Docker containers we use the docker stop command. The syntax is simple:
$ docker stop [OPTIONS] CONTAINER [CONTAINER...]
You can specify one or more container to stop. The only option for docker stop is -t (--time) which allows us to specify a time to wait before stopping a container. 10 seconds is the default value, which is supposed to be enough for the container to gracefully stop. To stop the container in a more brutal way, you can execute the following command:
$ docker kill CONTAINER [CONTAINER...]
What's the difference between docker stop and docker kill ? They will both stop a running container. There's an important difference though:
- docker stop: The main process inside the container will first ...