You can perform various operations on docker container like add, remove, stop, and list the docker container or docker image in the system. The docker commands used in this chapter are docker specific and do not have any dependencies on Smarts product.

Note:

In docker there is nothing called uninstallation, you just need to remove the container and the image file from the system.

To remove the docker containers and the image files, you need to perform the following series of task:

  1. Search for the list of container present on your system, run the following command to list the containers:

    #docker ps -a
    
  2. Run one of the following command, to attach the existing container (if any):

    #docker attach <container ID>
    or,
    #docker attach <container name>
    
  3. To stop the docker, run the following command:

    • Invoke the following command, to stop all the containers running on your machine:

      #docker stop $(docker ps -a -q)
      #docker stop <container ID>
      or,
      #docker stop <container name>
      
  4. To remove the container, run the following command:

    • Invoke the following command, to remove all the containers on your machine:

      #docker rm $(docker ps -a -q)
      #docker rm <container ID>
      or,
      #docker rm<container name>
      
  5. Search for the list of docker images present on your system, run the following command to list the docker image:

    #docker images --all
    
  6. Invoke one of the following command, to remove the image:

    #docker rmi <ImageID>
    or,
    #docker rmi <Image Name>
    
  7. Invoke one of the following command in the Docker container to exit or stop the container:

    #exit
    Ctrl + C
    Ctrl + \