ペアプロをしていただいて色々教えていただいたので、メモ
恥ずかしながらdockerのことをきちんとわかっておらず。
docker-compose.yml
version: "3"
services:
xxx: //コンテナのサービス名
container_name: xxx
image: sakusaku/xxx:latest
command: /bin/sh -c "rm -f tmp/pids/server.pid && bin/rails s -b 0.0.0.0"
build:
context: . //検索対象のディレクトリ
dockerfile: Dockerfile
volumes:
- .:/var/app/ //マウントのディレクトリを指定
- /var/app/node_modules //省く場合の記述方法
environment: //環境変数系
TZ: Asia/Tokyo
MYSQL_NAME: xxx
MYSQL_USER: root
WEBPACKER_DEV_SERVER_HOST: webpack
ports:
- 3000:3000
tty: true
stdin_open: true //cliとか
depends_on: //他のコンテナが起動してからにする
- webpack
- mysql
YYY:
container_name: YYY
image: sakusaku/xxx:latest
docker-compose build
imageを作成する
レイヤでないものをpullしたり
Dockerfile
docker imageをつくるレシピ
image: sakusaku/xxx:latest
の部分になる。