Docker Cheatsheet

 by Robin Wieruch
 - Edit this Post

A collection of all the Docker commands I am using on a regular basis for developing applications with Docker.

Docker Machine

List all Docker engines:

docker-machine ls

Create a Docker engine:

docker-machine create --driver virtualbox default

Set environment variables for Docker engine:

docker-machine env default
eval $(docker-machine env default)

Start a Docker engine:

docker-machine start default

Stop a Docker engine:

docker-machine stop default

Retrieve IP address for running Docker engine:

docker-machine ip default

Docker Images

List Docker images:

docker images

Remove Docker image:

docker rmi <image_id>
docker image rm <image_id>

Create Docker image (requirement: Dockerfile):

docker build -t <dockerhub_username>/<custom_docker_image_name> .

Docker Containers

List Docker containers:

docker ps
docker container ls -a

Stop and remove Docker container:

docker stop <container_id>
docker rm <container_id>

Remove all stopped Docker containers:

docker container prune

Create Docker container (requirement: Docker image):

docker run --name <custom_container_name> -p <new_port>:<defined_port> -d <dockerhub_username>/<custom_docker_image_name>

Docker Compose

If development, build, run and keep running (e.g. service_id equals dev):

docker-compose build <service_id>
docker-compose up <service_id>

If testing, build and run once (e.g. service_id equals test):

docker-compose build <service_id>
docker-compose run --rm <service_id>
Continue Reading:
Continue Reading:

Keep reading about 

If you are new to React, most likely you want to know how to display a list of items in React's JSX syntax. This tutorial for List components in React gives you a step by step walkthrough on how to…

Docker Compose helps you run multi-container applications. In this tutorial, we expand a Docker project, which has only a Dockerfile, with Docker Compose. Before you continue, make sure you have set…

The Road to React

Learn React by building real world applications. No setup configuration. No tooling. Plain React in 200+ pages of learning material. Learn React like 50.000+ readers.

Get it on Amazon.