Skip to content
English
  • There are no suggestions because the search field is empty.

Basic Docker Commands (Linux)

This article explains how to use essential Docker commands

General usage of Docker

On Linux, Docker operates as a background service (daemon) and is managed exclusively through the Command Line Interface (CLI). While graphical tools exist, the CLI is the standard and most powerful way to interact with Docker. It allows for quick command execution, easy automation, and precise control over container environments. This is particularly important when deploying complex multi-container applications like zapAnalytics using Docker Compose.

 

Topics:



Basic Docker CLI Commands

Docker is accessed via the docker and docker compose commands. Open your terminal and type the commands directly.

Depending on your installation, you may need to prefix commands with sudo unless your user is part of the docker group. We recommend adding your user to the docker group with sudo usermod -aG docker $USER after installing the Docker Engine.

Note: You may need to log out and back in for this change to take effect.

Command Description Example
docker --version Show installed Docker version  
docker pull <image> Download a Docker image from Docker Hub docker pull docker.io/zapliance/zapAnalytics:2.0.0
docker images List all locally stored images  
docker ps -a List all containers (running and stopped)  
docker rm <container_id> Remove a container docker rm 123abc
docker rmi <image_id> Remove an image docker rmi zapliance/zapAnalytics:2.0.0
docker logs <container_id> View container logs docker logs 123abc
  docker stop <container_id> Stops a specific container docker stop application_zapanalytics

 

Common Docker Compose Commands

docker compose is a tool for defining and managing multi-container 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, and start containers defined in the YAML file
docker compose up -d Start containers in detached mode (runs in the background)
docker compose pull Download the latest versions of the images defined in the YAML file
docker compose stop Stop the running containers without removing them.
docker compose down Stop & remove containers and networks created by up
docker compose logs -f Follow the live log output of all services defined in the YAML file

 

Quick Start: Runing 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 deploy 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 /opt/zapAnalytics

  • Start the container: docker compose up -d

  • Docker fetches/downloads all required images from the remote image registries. (you may copy these images to your own image registry beforehand and incorporate it to your deployment pipelines)
  • After 10-30 seconds you should be able to access the start page in the web browser

  • Check if container is running properly: docker ps -a

  • Stop and remove container: docker compose down

  • Remove image: docker rmi <image_name>

  • Add -f to force removal: docker rmi -f <image_name>

 

Update a Docker Image

To update a Docker image, follow these steps:

  1. Edit your YAML file

    Open docker-compose.yml and change the image tag to the desired version, for example:

    services:
      zapanalytics:
        image: zapliance/zapanalyticsplatform-prod:2.0.0
        container_name: application_zapanalytics
        restart: always

    ...

     

  2. Pull the new image and restart

    On Linux, Docker Compose handles the update process efficiently:

    • docker compose pull

    • docker compose up -d

    Docker will automatically download the new version while the old container is still running, then stop the old container, and start a new one using the updated image.

 

Force Update

If a standard update fails or if you encounter persistent configuration issues, you can perform a "clean" update.

Note: This will cause longer downtime because the old container is stopped first, then the image is deleted and the update downloaded.

  1. Edit your YAML file as described above

  2. Stop & remove old containers and images

    • docker compose down
    • docker rmi -f zapliance/zapanalyticsplatform-prod:<version>

    Replace <version> with the current tag (e.g., 2.0.0).

     

  3. Start the updated container
    • docker compose up -d
The container will now run the updated image version.

Resources for Further Learning