49
50

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

docker-composeでmysql & postgreSQL をサクッと起動

Posted at

DB docker-compose

随分前に書いてずっと下書きにに入れてた。

とりあえずDB使いたいに場合に気軽に起動できます。

mysql & postgresがdocker-compose up -dで起動します。

不要なDBはコメントアウトすればOK

docker-compose.yml
# mysql ---------------------------------------------
datastore:
  image: busybox
  volumes:
      - /opt/datastore:/var/lib/mysql
  container_name: mysql-datastore
mysql:
  image: mysql
  environment:
    MYSQL_ROOT_PASSWORD: password
  ports:
    - "3306:3306"
  volumes_from:
    - datastore
  container_name: mysql-db
# ---------------------------------------------------

# postgres ------------------------------------------
postgres-data:
  image: busybox
  volumes:
      - /var/lib/postgresql/data
  container_name: postgres-datastore

postgresql:
  image: postgres
  environment:
    POSTGRES_USER: hoge
    POSTGRES_PASSWORD: password
  ports:
    - "5432:5432"
  container_name: postgres-db
  volumes_from:
      - postgres-data
# ---------------------------------------------------
49
50
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
49
50

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?