• contact@mhichri.com

Docker useful commands

Docker useful commands

Docker ! You must heard of it !

Here are some useful commands that you need to master in order to manage containers with docker

docker run <image-name> ==> run a docker container with a specific image. Docker engine will load the image from local image repository, otherwise, it will fetch it from docker hub image repository
parameters :
-d ==> run container on background
-it ==> run container on interactive way (needs to specify a command, such as “/bin/bash” at the end of the line)
–name ==> give a name to a container
-p ==> bind the container port to a specific port in your application

docker version ==> get the docker server and client versions

docker info ==> get information about docker engine (number of running containers, swarm …)

docker images ==> lists docker images in local repository

docker ps ==> lists running containers

docker ps -a ==> lists all containers (even stopped once)

docker rmi <image-name|image_id> ==> remove image from local repository

docker pull <image-name>:<version> ==> download docker image (with specific version) from docker hub
For instance : docker pull ubuntu:14:04

docker start <container-id> ==> start a container

docker stop <container-id> ==> stop a container

docker rm <container-id> ==> delete a container

docker stop $(docker ps -aq) ==> stop all containers

docker rm $(docker ps -aq) ==> delete all stopped containers

docker rmi $(docker images -q) ==> delete all images from local repository


Leave your message