Skip to content

Instantly share code, notes, and snippets.

@tomoyk
Last active April 16, 2021 09:24
Show Gist options
  • Save tomoyk/e984589d99711347fd47fd57af6e90db to your computer and use it in GitHub Desktop.
Save tomoyk/e984589d99711347fd47fd57af6e90db to your computer and use it in GitHub Desktop.
phpmyadminとmysqlの環境を作るやつ
version: '3'
services:
db:
container_name: composed-mysql
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: foobar123
MYSQL_DATABASE: db_study
pma:
container_name: composed-pma
image: phpmyadmin/phpmyadmin
ports:
- "8080:80"
restart: always
environment:
PMA_HOST: db
PMA_USER: root
PMA_PASSWORD: foobar123
volumes:
db_data:
@tomoyk
Copy link
Author

tomoyk commented Sep 19, 2018

使い方

  1. GitやZipでダウンロード
$ git clone https://gist.github.com/tomoyk/e984589d99711347fd47fd57af6e90db
  1. Docker-Composeで起動
$ docker-compose up -d
  1. Docker-Composeで終了
$ docker-compose down

NOTE

以下のエラーが出るとき:

ERROR: for db  Cannot create container for service db: Conflict. The container name "/composed-mysql" is already in use by container "b8a321aeb7e438e21283bef9c2f5196a7ffbd889fe81731c54cbfc5d2ea3a246". You have to remove (or rename) that container to be able to reuse that name.
ERROR: Encountered errors while bringing up the project.

古いイメージが残っているので以下を実行

$ sudo docker ps -a  |  awk '{print $1}' | xargs sudo docker stop | xargs sudo docker rm

@tomoyk
Copy link
Author

tomoyk commented Sep 26, 2018

ブラウザから http://localhost:8080/ へアクセス!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment