LoginSignup
36
25

More than 5 years have passed since last update.

バージョン3のdocker-compose.ymlでvolumes_fromを使う

Last updated at Posted at 2019-01-14

バージョン3のdocker-compose.ymlで volumes_from が使えないので代わる方法。

docker-compose.yml
---
version: '3'

services:
  nginx:
    image: nginx:1.15.8-alpine
    :(省略)
    volumes:
      - document_root:/usr/share/nginx/html
    :(省略)

  wordpress:
    image: wordpress:5.0.3-php7.2-fpm-alpine
    :(省略)
    volumes:
      - document_root:/var/www/html
    :(省略)

volumes:
  document_root:
    driver_opts:
      type: none
      device: /path/to/host
      o: bind

解説

トップレベルで volumes を書いてそれを各サービスで共有する。こうするとvolumes_fromと同じように使える。

driver_opts はマウントするときのオプションを指定できる。例えば nfs の場合は typenfs を指定すると良い。

36
25
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
36
25