LoginSignup
4
0

More than 5 years have passed since last update.

Dockerfileのベースイメージをmysqlに指定した時に、sequel proに接続する方法

Last updated at Posted at 2019-03-07

はじめに

Dckerfile

FROM mysql:5.7
docker-compose.yml
version: '3'
services:
  web:
    build:
      context: .
      dockerfile: ./Dockerfile
    volumes:
      - .:/data
    ports:
      - '3000:3000'
    environment:
      - MYSQL_ROOT_PASSWORD=password

ベースイメージをmysqlにしているときに
webアプリケーションにlocalhost:3000で接続でき、sequel proにも接続したい。

Sequel Proの接続情報
host: 127.0.0.1
user: root
pass: password
port: 3000

これで接続できると思っていたが、接続できなかった。

解決方法

アプリ側のポートに"3306"を追加する

docker-compose.yml
version: '3'
services:
  web:
    build:
      context: .
      dockerfile: ./Dockerfile
    volumes:
      - .:/data
    ports:
      - '3000:3000'
      - '3306:3306' # 追加
    environment:
      - MYSQL_ROOT_PASSWORD=password

Sequel Proの接続情報
host: 127.0.0.1
user: root
pass: password
port: 3306

これで接続できた。めでたし、めでたし。

4
0
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
4
0