Basic Docker Commands (CLI)
This article explains how to use essential Docker commands
General usage of Docker
Docker can be used in two primary ways: through the Command Line Interface (CLI) or via Docker Desktop, a graphical user interface application available for Windows and Mac. While Docker Desktop offers an easy-to-install and user-friendly graphical environment to manage containers, images, and settings, most Docker users find the CLI to be the more straightforward and flexible way to work with Docker on a daily basis. The CLI allows quick command execution, automation, and greater control, which is especially helpful when deploying complex multi-container applications like zapAnalytics using Docker Compose.
Note: Docker CLI is included in Docker Desktop.
Topics:
Basic Docker CLI Commands
Docker is accessible via the docker and docker compose CLI commands. You can open your terminal (Linux/Mac) or command line (cmd in Windows) and type Docker commands directly. Here are the most important commands when using Docker:
| Command | Description | Example |
|---|---|---|
docker --version |
Shows Docker version | docker --version |
docker pull <image> |
Download a Docker image from Docker Hub | docker pull zapliance/zapAnalytics:latest |
docker images |
Lists all downloaded/local images | docker images |
docker ps -a |
List all containers (running and stopped) | docker ps -a |
docker rm <container_id> |
Remove a container | docker rm 123abc |
docker rmi <image_id> |
Remove an image | docker rmi zapliance/zapAnalytics:latest |
docker logs <container_id> |
View container logs | docker logs 123abc |
Common Docker Compose Commands
docker compose is a tool for defining and managing multi-container Docker applications with a YAML file (docker-compose.yml). It simplifies running linked containers with a single command.
| Command | Description |
|---|---|
docker compose up |
Build, (re)create, start containers defined in docker-compose.yml |
docker compose up -d |
Same as above, but runs containers in detached mode (background) |
docker compose down |
Stop and remove containers, networks created by up |
Quick Start to Run zapliance Docker Images
zapliance will provide a docker-compose.yml file with default configuration during the onboarding. You can then use basic Docker commands to run it.
First, open the command line and navigate to the folder where the docker-compose.yml file has been placed:
-
-
Change directory in command line (example, please choose the appropriate directory):
cd D:/zapAnalytics/ -
Startup the container:
docker compose up -d - After 10-30 seconds you should be able to access the start page in the web browser
-
Check running docker container state:
docker ps -a
-
-
- Stop container:
docker compose down -
Remove image:
docker rmi <image_name> -
Add -f to force removal
docker rmi -f <image_name>
- Stop container:
Update a Docker Image
To update a Docker container, follow these steps:
-
Edit your
docker-compose.ymlChange the image tag to the desired version, for example:
services:
zapanalytics:
image: zapliance/zapanalyticsplatform:1.4.0
container_name: application_zapanalytics
restart: always...
You can also use
latestas the tag if you want the newest version. -
Stop and remove old containers and images
-
docker compose downdocker rmi -f zapliance/zapanalyticsplatform:<version>
Replace
<version>with the current tag (e.g.,1.4.0orlatest). -
-
Start the updated container
docker compose up -d
Resources for Further Learning
- Docker official documentation: https://docs.docker.com/
- Docker Compose documentation: https://docs.docker.com/compose/
- Docker Hub (container image repository): https://hub.docker.com/