postgre docker-compose.ymlとして使用

472 ワード

docker-compose.ymlを使用しない場合は、以下のようにコードを書くたびに作成できます.
$ docker run -p 5432:5432 --name postgres -e POSTGRES_PASSWORD=1q2w3e4r -d postgres
docker-compose.ymlファイルには、次のコードが記述されます.
postgres:
  image: postgres:11.10-alpine
  container_name: postgres
  hostname: postgres
  ports:
    - 5432:5432
  restart: always
  environment:
    - POSTGRES_USER=postgres
    - POSTGRES_PASSWORD=postgres