sketchpad

A collection of personal and technical notes.

View the Project on GitHub arantebw/sketchpad

docker

docker build

Build multiple images simultaneously.

docker build -t <dockerhub_username>/<image_name>:0.0.0 -t <dockerhub_username>/<image_name>:latest .

Build a new Docker image with a Dockerfile.

docker build -t <dockerhub_username>/<app_name>:<version> .
docker build -f <dockerfile> .

docker container

List all of the running containers on a host machine.

docker container ls

Rename an existing <container> to <new_name>.

docker container rename <container> <new_name>

docker context

List all of the available Docker context on a host machine.

docker context ls

docker compose

Check the current version of Docker compose installed.

docker compose version

Run and/or build a docker-compose.yml file.

docker compose up
docker compose up --build
docker compose stop
docker compose down

Restart Policies:

docker compose ps

docker exec

Executes a one-off <bash_command> in the container.

docker exec <container_id> <bash_command>

Start a shell session within the container.

docker exec -it <container_id> /bin/sh

docker image

Remove a local copy of an image.

docker image rm <dockerhub_username>/<image_name>:<tag>

List all of the available images on a host machine.

docker images
# Or,
docker image ls

docker kill

This stops the container by issuing a SIGKILL signal to the container.

docker kill <container_id>

docker logs

Display all the container logs.

docker logs <container_id>

docker network

Create a new custom bridge network.

docker network create <network_name>

List custom bridge networks.

docker network ls

docker ps

List all running containers.

docker ps

List all running/stopped containers.

docker ps -a

-a or --all.

docker rm

Remove a specific Docker container.

docker rm <container_id>

docker run

Run a Redis server.

docker run --name redis-server -d -p 6379:6379 redis

Download/execute the hello-world Docker image.

docker run hello-world

Run a MongoDB server as <container> with exposed port using the mongo:4.2.23 image.

docker run --name <container_name> -d -p 27017:27017 mongo:4.2.23

Note:

docker run -d -p 3001:2368 -v ghost-vol:/var/lib/ghost/content -e NODE_ENV=development -e URL=http://localhost:3001 ghost

Note:

docker run -d --network none docker/gettting-started
docker exec <container_id> ping google.com -W 2 # returns an error
# ping: bad address

Note:

docker pull

Downloads an image from Dockerhub.

docker pull <image_name>
docker pull <dockerhub_username>/<image_name>:<tag>

docker push

Push multiple images to Docker Hub simultaneously.

docker push <dockerhub_username>/<image_name> --all-tags

Push the image to Docker Hub.

docker push <dockerhub_username>/<image_name>:<tag>

docker start

Run a previously stopped container.

docker start <container_name>

docker stop

This command stops a running container by issuing a SIGTERM signal to the container.

docker stop <container_id>

Stop all running processes.

docker stop $(docker ps -q)

docker system

Remove all stopped containers, build cache, networks, and volumes.

docker system prune
# or
docker system prune -a

docker version

Check the details of the Docker tools installed in your machine.

docker version

Check the current version of Docker engine installed.

docker --version

docker volume

Create a new storage volume.

docker volume create <volume_name>

List all of the existing storage volume.

docker volume ls

Show the details of an existing storage volume.

docker volume inspect <volume_name>