docker run :

Docker run command is use to run the container from an image. when we run docker run < image-name >, docker-api sends this command to docker daemon which will create an instance of image (container) application into the docker host.

First It will search the image from docker host system if it found then it will create an container otherwise it will go out to docker hub and pull the image. From second time onwards if we run the same image docker will find that in docker host system and won't go out to docker hub.


docker pull <Image NAME>:

Docker pull command will download an image and store it on our host machine.


docker ps :

Docker ps command list all the running container along with some basic information such as CONTAINER ID, IMAGE, COMMAND, CREATED, STATUS, PORTS and NAMES. CONTAINER ID and NAMES are automatically created by docker.


docker stop <CONTAINER ID/NAMES>:

Docker stop command will stop a running container.


docker rm <CONTAINER ID/NAMES>:

Docker rm command will remove a stopped or existed container permanently.


docker images :

Docker images command will list all the available images from host along with some basic information such as REPOSITORY, TAG, IMAGE_ID, CREATED and SIZE.


docker rmi <Image NAME>:

Docker rmi command will remove a stopped or existed container permanently.

We need to make sure that all the depedent conatainers are deteled before removing the image.


docker exec < container_id/name >:

Docker exec container_name will allow us to run the command into the conatainer.

If we want to perform any task with-in the container such as view/edit/print the content of a file, run the specific job inside container, we can use exec command.