前提
Dockerはすでにつかえるということが前提となっています
手順
- プロセスの立ち上げ
$ docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres
- postgresqlが立ち上がっているかどうかの確認
$ docker run -it --rm --link some-postgres:postgres postgres psql -h postgres -U postgres
- ファイルを任意の場所に作成し、以下を書き込む
# stack.yml
Example stack.yml for postgres:
# Use postgres/example user/password credentials
version: '3.1'
services:
db:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: example
adminer:
image: adminer
restart: always
ports:
- 8080:8080
$ docker-compose -f stack.yml up
- localhost:8080でブラウザ確認
ユーザー名とパスワードを入力する画面が出てくる
それぞれ下記のものを入力する
ユーザー名 postgres
パスワード example