Docker

DevOps Docker

Common command

command description
docker login Login to docker hub
docker push Push the image to docker hub
docker pull {IMAGE_NAME} Pull the image from docker hub
docker run {IMAGE_NAME} Run containers
docker run -d {IMAGE_NAME} Run containers on detached mode (Background)
docker image inspect {IMAGE_NAME} Get image info
docker exec -ti {CONTAINER_NAME} bash Go into the current running container and using the bash
docker start {CONTAINER_NAME} Start stopped containers
docker stop {CONTAINER_NAME} Stop containers
docker kill {CONTAINER_NAME} Kill containers
docker top {CONTAINER_NAME} Check the current container process
docker ps List running containers
docker ps -a List running and stopped containers
docker info Display system information
docker images Lists images
docker version Display the system’s version

Common options

options description
-d Detach the container to the background
-i Allow interactive with the container
-t Allow using tty with the container
-p expose socker from ouside port:inside port (e.g. 8080:80)
–restart Always restart the container if it runs fail
–rm Remove the container while the container finish its job

Docker CLI Cheet Sheet

Limits

command description
docker run –memory=“256m” nginx Max Memory
docker run –cpus=".5" nginx Max CPU

Attach

command description
docker run –it nginx – /bin/bash Attach shell
docker run –it – microsoft/powershell:nanoserverpwsh.exe Attach Powershell
docker container exec –it {CONTAINER_NAME} –bash Attach to running container

Cleaning up

command description
docker rm {CONTAINER_NAME} Remove stopped containers
docker rm $(docker ps -a -q) Remove all stopped containers
docker rmi {IMAGE_NAME} Delete the image
docker system prune -a Removes all images not in use by any containers

Container Registries

Reference


Build Image

DevOps Docker Build Image

Images

DevOps Docker Images

Container

DevOps Docker Container

Volume

DevOps Docker Volume

Log

DevOps Docker Log

Docker Compose

DevOps Docker Compose

Network

DevOps Docker Network

Scheduling

DevOps Docker Scheduling

Monitor

DevOps Docker Monitor

Use case

DevOps Docker Use case