In this blog post we will see some of the basic docker commands to interact with containers and images.
[What is Docker? Containers and its Architecture. Learn more!]
Creating and running a container from an image
$ docker run <image_name>
$ docker run hello-world

$ docker run <image_name> <command>
$ docker run busybox echo hello there , $ docker run busybox ls

List all running containers
$ docker ps, docker ps –all
docker ps command lists the current running containers and docker ps –all lists all containers used till now


One of the common uses of docker ps is not only to check what is running but also to find the ID of the run container!
Restarting Stopped Containers
$ docker start -a <ContainerID>
find container ID by running $docker ps –all

Removing Stopped Containers
$ docker system prune
this command will remove all the stopped containers

Get logs from the Container
$ docker logs <container id>

Stopping a Container – in two ways
$ docker stop <container id>
stops the container after ending other process inside of the container
$ docker kill <container id>
immediately stops the container without any wait