#90DAYSOFDEVOPSCHALLENGE

Day 20 Task: Docker Cheat-Sheet.

Abhay Vishwakarma
3 min readFeb 6, 2023

Commands to setup docker in EC2 :

* sudo yum update -y

* sudo amazon-linux-extras install docker

* sudo service docker start

* sudo systemctl enable docker

* sudo usermod -a -G docker ec2-user (Permissions denied)

• General Management :

*It will allow you to obtain general information about the system and connect to remote Docker resources.

  • To log / logout in to a Docker registry :
docker login
docker logout
  • To show the version of the local Docker installation :
docker version
  • Display information about the system :
docker info

• Container Management :

*Here we show how to create, manage, and remove containers from your Docker system.

  • To see the containers currently running on the system :
docker ps
  • To see all the containers, both running and non-running :
docker ps -a
  • To create a container :
docker create [image]
  • To rename an existing container :
docker rename [container] [new_name]
  • Delete a container :
docker rm [container]
  • To view logs for a running container :
docker logs [container]
  • Update the configuration of one or more containers :
docker update [container]
  • To view port mapping for a container :
docker port [container]
  • To show running processes in a container :
docker top [container]
  • To view live resource usage statistics for a container :
docker stats [container]
  • To show changes to files or directories on the filesystem :
docker diff [container]
  • To copy a local file to a directory in a container :
docker cp [file-path] CONTAINER:[path]

• Running a Container :

*Here a commands show you how to start and stop processes in a container.

  • Run a command in a container based on an image :
docker run [image] [command]
  • To establish a connection with a container by mapping a host port to a container port :
docker run -p [host-port]:[container-port] [image]
  • To start / Stop / restart / wait / kill / attach a container :
docker start [container]
docker stop [container]
docker restart [container]
docker wait [container]
docker kill [container]
docker attach [container]

• Image Management :

*Here a commands for working with Docker images.

  • Create an image from a Dockerfile. And docker build [dockerfile-path].
docker build [dockerfile-path]
docker build .
  • Create an image from a Dockerfile and tag it.
docker build -t [name]:[tag] [dockerfile-path]
  • To Pull / Push / history an image from a registry :
docker pull [image]
docker push [image]
docker history [image]
  • Remove unused images :
docker image prune

• Plugin Management :

  • To enable / disable a Docker plugin :
docker plugin enable [plugin]
docker plugin disable [plugin]
  • Create a plugin from config.json and rootfs :
docker plugin create [plugin] [path-to-data]
  • To docker plugin create [plugin] [path-to-data].
docker plugin rm [plugin]

Thank you for reading this blog. I hope you find this really interesting.

If you like it then press ‘Clap’ button and Follow me on Linkedin & Github platform.

— Abhay Vishwakarma

*References :-

!If you want more info then visit here….Docker Cheat Sheet”……..!!!

--

--