Managing Container in Docker: Creating, Starting, Stopping and Deleting Container

In Docker, you can manage container by creating, starting, stopping, and deleting them. Here is a detailed guide on managing container in Docker:

 

Creating a Container

To create a container, you need to use an existing image. Use the docker run command along with the image name and any necessary options.

For example, docker run -it --name mycontainer nginx will create a new container from the "nginx" image and name it "mycontainer".

 

Starting a Container

To start a created container, use the docker start command followed by the container name or ID.

For example, docker start mycontainer will start the container named "mycontainer".

 

Stopping a Container

To stop a running container, use the docker stop command followed by the container name or ID.

For example, docker stop mycontainer will stop the container named "mycontainer".

 

Deleting a Container

To delete a stopped container, use the docker rm command followed by the container name or ID. For example, docker rm mycontainer will delete the container named "mycontainer". Note that the container must be stopped before deletion.

 

Listing Container

To list all running container, use the docker ps command. To list all container including stopped ones, use the docker ps -a command.

 

Please note that the above commands provide some additional options to adjust the behavior and configuration of container. Refer to the Docker documentation for more detailed information on options and guidelines for managing container in Docker.