Introduction to Docker

👋 Thanks for reading! Things have changed since this was written, take it with a grain of salt ;)

Build an Image

# to build an image of the current directories docker file
docker build -t <name> .

List Images

docker images

Run Image

docker run <name>

# run with a user and tag
docker run -i -t -u 0 cp_test:latest

Launch an Images Shell

# list running containers
docker ps

# connect to it
docker exec -it <running_cont_id> bash

# or just launch an ubuntu shell directly
docker run -i -t ubuntu /bin/bash

Inspect Image

docker inspect <repo:tag or id>

Clean Up

A few clean up commands:

# Remove everything
docker prune

# containers
docker rm $(docker ps -a -q)

# images
docker rmi $(docker images -q)

Remove Images by Name

# get image id
docker images
# delete image
docker rmi -f <image id>

Docker Composer

Run a Docker Image

# add -d flag for daemon mode
docker-compose up

What is Running

docker-compose ps

Stop Running

docker-compose stop