Docker Host

Machine on which the Docker containers run. It can be a virtual machine or a physical machine

Container Image/Docker Image

This is used to start the container

Dockerfile

Shell script for creating Docker image/Container image

# vim application.Dockerfile 
FROM ubuntu:20.04                             //FROM Command: Installation is based image this OS, Since docker is not full OS.
RUN apt update \                              //RUN Command: Run some command
    apt-get install -y --no-install-recommends openssl \
    apt-get install -y --no-install-recommends iputils-ping \

COPY ./application.out ./a.txt /app/

CMD /app/application.out "--config" a.txt     //CMD Command: Start the application
        

Docker Registry

Stores docker images. Same as github,gitlab are for source code. Eg: dockerhub, elastic container registry(ecr)

Docker Volume

This is a persistent storage location managed by Docker, outside the container’s filesystem.
Helpful when you want to store data present in database across container reboots/deletion/recreation.
Volumes are defined in docker-compose.yml and mapped to a path inside the container.
volumes, bind mounts, tmpfs all are seen as mounted directories to container.

Name of docker volume:
Docker Compose auto-generates the volume name as project-name_volume

// Check volumes
> docker volume ls
go-server_db_data

// Delete a volume
> docker volume rm go-server_db_data
go-server_db_data
        

Example (Mounting logs from 1st to 2nd container)

1. golang app running inside go_app container writes logs to /logs/app.log
2. container_logs folder is mounted inside go_app container. Hence logs are copied to container_logs(on host)
3. alloy_container mounts container_logs folder inside container & hence logs written by gp_app container are read inside alloy container

// Mount Command Syntax
# mount device(src) dst 
mount /dev/sdb1 /mnt/mydrive

# deployment.yaml
services:
  app:
    container_name: go_app
    volumes:
      # mount src dst
      # Mount /container_logs(host) to logs(container). Application will write logs to /logs/app.log
      # Now logs would be present on host inside container_logs
      - ./container_logs:/logs

  alloy:
    container_name: alloy_container
    volumes:
      # mount src dst
      # Mount folder(container_logs on host) to (/tmp/app_logs) inside the alloy container
      # Now alloy can access files written in ./container_logs on the host
      - ./container_logs:/tmp/app_logs/
        

Mounts, tmpfs

Does not persists data across reboots