Container Management
This guide will cover the basics of container management using Docker. We will discuss the possible options for managing containers, including starting, stopping, restarting, removing, and inspecting them.
Starting a Container
To start a container, you can use the docker run
command followed by the name of the image you want to run. For example, to start a container using the nginx
image, you can use the following command:
$ docker run -d -p 80:80 nginx
This command will start the container in detached mode (-d
flag) and map port 80 of the container to port 80 of the host (-p 80:80
flag).
Stopping a Container
To stop a container, you can use the docker stop
command followed by the container ID or name. For example, to stop a container with the ID abc123
, you can use the following command:
$ docker stop abc123
Restarting a Container
To restart a container, you can use the docker restart
command followed by the container ID or name. For example, to restart a container with the name my-nginx
, you can use the following command:
$ docker restart my-nginx