DevOps Classroom notes 21/Sep/2026

tempfs mount volume:

  • Data is store in hosts memory
  • never store data in hard disk
  • store information when running container untill stop

–tmpfs /app/tmp:

Example: httpd server need access file faster

docker run -dit  --name apache2 --tmpfs /usr/local/apache2/htdocs/:rw,size=64m httpd:latest

Docker compose

  • Docker compose define and run multiple container from a single yaml file
  • compose.yaml or docker-compose.yaml

Basic structure

services:
    web:
      image/build:
      port:
      volume:
      network:
    frontend:
      image/build:
      port:
      volume:
      network:
    backend:
      image/build:
      port:
      volume:
      network:

volumes: # named volumes
  demo:
  app:
  api:

networks:
  host:
  - app-net

sample docker compose file

services:
  apache2:
    image: httpd:latest
    container_name: apache2_container
    ports:
      - "80:80"
    volumes:
      - ./html:/usr/local/apache2/htdocs/
    networks:
      - webnet
    depends_on: ["mysql"]
  mysql: 
    image: mysql:latest
    container_name: mysql
    ports:
      - "3306:3306"

networks:
  webnet:
    driver: bridge

volumes:
  html:
    driver: local

Docker compose comands

  1. docker compose up -d # run docker services , create network and volume
  2. docker compose ps # list services runing
  3. docker compose logs -f apache2
  4. docker compose exec apache2 sh`` or /bin/bash“`
  5. docker compose down
  6. verbose -vvv docker compose down -v
  7. docker compose config # validate or view the final configuration
  8. -f file path docker compose up -d -f ./app-compose.yaml

common Service keys

  • image: prebuild image or existing image (image: http:latest)
  • build: build the image from dockerfile (build: ./Dockerfile)
  • port: Publish Port [host:containerport] (“8080:80”)
  • enviroment: set env varaible ( – KEY=Value)
enviroment:
  - name: demo
  - app: 1.2
  - team: devops 
  • env_file: local env file (env_file: .env)
  • volume: mount volume path to container - ./html:/usr/local/apache2/htdocs/
  • depends_on: starting order or wait for other service (depends_on: [“web”])
  • network: Attach network to container
networks:
 - webnet
  • restart: Restart policy automatically start container if any failures ( restart: unless-stopped )
  • command: override default command (command: [“java”, “-jar”, “*.jar”])
  • Health-check: container health test (healthcheck: cmd)

Task:

  1. try convert nop app and database as docker compose yaml file.

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%