Working with containers

If you are interested in checking all the containers running on your host, you can use the ps command as follows:

docker ps

The preceding command will list all the containers running on your host. If you also want to check the images that are not running, you can use the -a flag. After executing the preceding command, you'll have an output in your terminal similar to the following screenshot:

The Docker ps command output

The first column of the preceding screenshot explains the information in the following list. The most useful part of this output is the CONTAINER ID, which can be used to perform the following operations:

  • Restart the container:
docker restart <CONTAINER ID> 
  • Stop the container:
docker stop <CONTAINER ID> 
  • Start the container:
docker start <CONTAINER ID> 
  • Remove the container:
docker rm <CONTAINER ID>

These are the most common commands, and they provide all that you need in order to start working with Docker containers.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.96.105