In part one, we'll explore the Docker CLI and run through the steps to start a single container. Through this, you'll gain a general understanding on how to view various resources (containers, volumes, networks, etc) and how to manage them.
# Run `docker` with no arguments for help
docker
# Run `docker COMMAND --help` for help on a given command
docker container --help
docker network --help
# Run `docker COMMAND SUBCOMMAND --help` for further help
docker container run --help
docker volume ls --help
# List volumes
docker volume ls
# Create a volume called `ignition-data` for our gateway
docker volume create ignition-data
# List current Docker networks
docker network ls
# Create a dedicated bridge network for our container[s]
docker network create ignition-net
# List installed images
docker image ls
# Pull `inductiveautomation/ignition` image with `8.1.19` tag from Docker Hub
docker pull inductiveautomation/ignition:8.1.19
# List running containers
# NOTE: the implicit command for `docker` is `container`,
# so `docker ps` is equivalent shorthand.
docker container ps
# List all containers (including stopped)
docker container ps -a
# Create an Ignition container
# NOTE: We use backslashes on Unix-like systems to escape the
# newlines. You'd use backticks on Powershell (Windows).
docker container create \
-p 9088:8088 \
-e IGNITION_EDITION=standard \
-v ignition-data:/usr/local/bin/ignition/data \
--network ignition-net \
--name ignition-pt1 \
inductiveautomation/ignition:8.1.19 \
-n Ignition-part-one \
-m 1024
# List all non-running containers
docker container ps -a
# Start the container
docker container start ignition-pt1
# List running containers
docker container ps
# Inspect configuration JSON of container
docker container inspect ignition-pt1
# View the logs of the container
docker logs ignition-pt1
# Follow the logs of the container starting with the last 10 lines
docker logs --tail=10 -f ignition-pt1
# Open a `bash` shell within the container (ctrl-d to logout when done, or type `exit`)
docker exec -it ignition-pt1 bash
# Stop Ignition container
docker stop ignition-pt1
# Restart (or start when stopped) Ignition container
docker restart ignition-pt1
# Remove the Ignition container (only valid when stopped)
docker rm ignition-pt1
# Remove the Ignition named volume (only valid when container is removed)
docker volume rm ignition-data
# Remove the Ignition bridge network (only valid when no running containers are attached)
docker network rm ignition-net
# Use `docker run` to combine Create+Start
# NOTE: this will also automatically create the named
# volume `ignition-data` if not present.
docker run \
-d \
-p 9088:8088 \
-e IGNITION_EDITION=standard \
-v ignition-data:/usr/local/bin/ignition/data \
--network ignition-net \
--name ignition-pt1 \
inductiveautomation/ignition:8.1.19 \
-n Ignition-part-one \
-m 1024
# Chain commands together with `&&` (works with PowerShell, too)
docker stop ignition-pt1 && docker rm ignition-pt1
# Use tools like `jq` with JSON output for colorizing and additional filtering/querying
# ref: https://stedolan.github.io/jq/
docker inspect ignition-pt1 | jq