We earn commission when you buy through affiliate links.
This does not influence our reviews or recommendations.Learn more.
Docker is a popular tool to build and run containerized applications.
It is available for multiple platforms and used as one of the back-end container technologies in Kubernetes.
Once your image is ready, you might launch your containers using those images.
A container is a running instance of a Docker image.
In this article, well be focusing on managing containers using the docker command.
But this is done the only first time.
For subsequent times the same image is reused.
If you want to run a particular version of an image, specify its version separated by a colon.
This is known asTag.
In case you dont specify any tag, docker will consider it by default as the latest.
ps Command
docker pscommand lists all running containers and some basic information about them.
Each container gets a random name (if not specified explicitly) and ID.
stop Command
docker stopcommand is used to stop a running container.
Here we need to put container name or ID along with this.
On success, it would return the docker name or ID.
This will return theCONTAINER IDwhich you’ve got the option to use to stop the container.
rm Command
docker rmcommand removes a stopped or exited container.
exec Command
We can useexeccommand to go inside a running container.
This is useful to debug running containers or do some stuff within a container.
Here the flag-istands for interactive mode and-tfor the terminal.
Multiple containers can be specified to kill them in one go.
rename Command
To rename an existing container, userenamecommand.
diff Command
We can inspect changes to files or directories on a containers filesystem withdiffcommand.