Docker commands cheat sheet

We will discuss commands to create docker image,container,run,start and stop and different aspects.

create an docker image from docker file — docker build -t Imagename . (make sure you are in the docker file location before you execute the above command)

  1. Pull Docker Image.
docker pull Imagename

2. start a docker container in interactive session.

 docker run -t -i Imagename /bin/bash

3. start a docker container in background ( d- refers to deamonize the conatiner)

docker run -d Imagename /bin/bash

4. To name a container while its starting

docker run -it -name <conatinername> <dockerimage>
OR
docker run -d -name <conatinername> <dockerimage>

Manage Docker Containers

create docker image from running containers.

docker commit -m”message for image” ‘<conatinername/Id>’ <imageName>

docker ps -a — list all docker container both running and stopped

docker ps — list all docker running container

docker start ContainerName/id — start a stopped docker conatiner with the specified ContainerName

docker stop containername/Id — stop the container with the name.

docker rm -f $(docker ps -aq) — delete all the(run&stoppped) conatiners in the host.

docker inspect containername/id— get the details (meta data like, hostsname ,ipaddress, network information etc..)of the container.

docker restart containername/Id — restart docker container

docker stats containerName/Id — gets us the cpu,memory and network utilization of the containers.

Commands inside docker containers

to see the number of different process running inside the containers

docker top <continername/Id>

Manage Docker images

docker rmi dockerimage — remove the docker image

docker imges— list all the exitng images in the current docker engine.

Manage Docker Cluster

Show your support

Clapping shows how much you appreciated Venkata Chitturi’s story.