Starting and stopping containers
Let's go back a little and begin with the basics: how to run and stop the Docker container manually, from the shell or the command line.
Starting
As you have seen in the previous chapters, to spin-up the container from the image, we use the docker run
command. The running container will have its own file system, networking stack, and isolated process tree separate from the host. As you will remember from Chapter 5, Creating Images with Java Applications, every singledocker run
command creates a new container and executes a command specified in the Dockerfile, CMD
, orENTRYPOINT
.
The syntax of the docker run
command is as follows:
$ docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
The command takes the image name, with the optional TAG
or DIGEST
. If you skip the TAG
and DIGEST
command parameters, Docker will run the container based on the image tagged latest
. The docker run
command also takes a set of possible options you may find useful, such as the runtime...