Docker command lines

In this post i ll show the most common command lines used to help you work with Docker:

•docker ps : displays the list of containers running (use docker ps -a to see all containers, running and stopped).

•docker build : Build a container from a docker file.

•docker images : displays the list of available images into your host.

•docker run : Runs a container from a specific image (if the image is not yet present into your host, it will download it).

•docker start : Starts a container present into your host.

•docker stop : Stops a container present into your host.

•docker rm : Removes a container present into your host.

•docker rmi : Removes an image present into your host.

•docker cp : Similar to an scp command line, it will copy from your host to your docker or from docker to your host.

•docker commit : Allows you to create a new image from container changes.

•docker inspect : Helps you to get metadata from different docker components such as networks, volumes, ….

•docker network : Manage network components (Usefull to isolate container to a network or bridge connection with other container or your host).

Usefull commands:

Stop all the containers at once: docker stop $(docker ps -a -q)

Delete all the container at once: docker rm $(docker ps -a -q)

Delete all the images at once (you must delete the containers before first): docker rmi -f $(docker images -q)