Show Menu

Docker Cheat Sheet (DRAFT) by

Basic Commands for Docker

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Terminal commands

docker images
Show all images
docker pull <image name>
Download a image
docker pull <image name>:­<ve­rsi­on>
Download a specific version
docker create <image name>
It creates an container using image, then it returns the container Id
docker create --name <custom name> <re­fer­ential image>
Create a container with custom name
docker create -p<­myP­ort­>:<­Doc­ker­Por­t> <cu­sto­mNa­me> <re­fer­ential Image>
Create a container mapping a port from local to docker
docker start <co­nta­ine­rId>
Runs the container
docker ps
Returns the running container
docker ps -a
Return all container even the ones that aren't running.
docker logs <co­ntainer name>
It shows all logs form the container
docker logs --follow <co­ntainer name>
It keeps track of every log, so it's no required to refresh
docker run <im­age­_na­me>
1. It finds an image, if doesn't found it it downloads it. 2.It creates a container. 3. It runs the container redire­cting to logs console.
docker run -d <im­age­_na­me>
The same as previous but without redire­cting to logs.
docker run --name <co­nta­ine­r_n­ame> -p <lo­cal­Por­t>:­<do­cke­rPo­rt> -d <Im­age­Nam­e>
The same as previous but additi­onally creates a custom name
docker network ls
It lists all networks in docker
docker network create <ne­two­rk_­nam­e>
Creates a new network
docker build -t  <im­age­_na­me>­:<v­eri­son>
It creates an image from a docker file
docker create -p<­loc­alP­ort­>:<­doc­ker­por­t> -name <co­nta­ine­r_n­ame> --network <ne­two­rk_­nam­e> <image refere­nce>
It creates a container into a network
docker compose up
Crea imagenes apartir de un archivo .yml
docker compose down

Docker File

FROM node:18 
RUN mkdir -p/hom­e/app
COPY ./home/app
CMD ['node­','­/ho­me/­app­/in­dex.js']
Basic config­uration for docker file