docker参考書では教えてくれないymlの設定🙄。 #docker

2022.12.20

Logging

おはようございます、勉強しているのですが自信がない…。

Dockerをどっか~ん、はいスミマセンおじさんギャグです🙇。ヤムルファイルとDockerファイルを使うと結構手抜きが出来るですね。この頃、Dockerの良いところを取り入れたサービスが新たに登場しましたよね。Finchとか言う奴です・・・AWSが提供しているやつ🙄。

自分は当分、Dockerを使います。Dockerを使用していた前はVirtualBoxでした。他にもVagrant(ベイグラント)に浮気したこともありますが、Dockerを使用してからは他の仮想サービスより使いやすい事が分かりました。使っている人が多いとヤムルファイルやDockerファイルもネットにゴロゴロ転がっていますからね。

さて、最後に自分が使っているymlファイルの設定です、いらない部分もあるかもですがご自由にご使用ください。

    build:
      context: .
      dockerfile: Dockerfile
version: "3"
services:
  web:
    image: almalinux:latest
    container_name: test_v0
    restart: always
    ports:
      - 443:443
      - 80:80
    privileged: true
    command: /sbin/init
    extra_hosts:
      - "taoka-test.com:127.0.0.1"
    volumes:
      - X:/var/www/html:/var/www/html
    build:
      context: .
      dockerfile: Dockerfile
  mysqldb:
      image: mysql:latest
      container_name: test_db_v0
      command: --default-authentication-plugin=mysql_native_password
      restart: always
      hostname: testdbhost1
      environment:
        MYSQL_USER: hogeuser
        MYSQL_PASSWORD: password
        MYSQL_DATABASE: hoge_db
        MYSQL_ROOT_PASSWORD: password
        TZ: "Asia/Tokyo"
      ports:
        - 3306:3306
      expose:
        - '3306'
      volumes:
        - X:/var/test/db/mysql_init:/docker-entrypoint-initdb.d
        - X:/var/test/db/mysql_data:/var/lib/mysql
      tty: true
  postgresdb:
      image: postgres:latest
      container_name: test_postdb_v0
      restart: always
      hostname: testdbhost2
      environment:
        POSTGRES_USER: hogeuser
        POSTGRES_PASSWORD: password
        PGPASSWORD: password
        POSTGRES_DB: hoge_db
        TZ: "Asia/Tokyo"
      ports:
        - 5432:5432
      expose:
        - '5432'
      volumes:
        - X:/var/test/db2/postgres_init:/docker-entrypoint-initdb.d
        - X:/var/test/db2/postgres_data:/var/lib/postgresql/data
      tty: true

タグ

-Command, context, default-authentication-plugin, docker, Environment, expose, Finch, hostname, init, latest, MYSQL, password, ports, postgres, postgresql, sbin, services, tty, Vagrant, virtualBOX,