LoginSignup
4
1

More than 3 years have passed since last update.

docker-compose.yml version 3 で volumes_from を指定する(Windows向け)

Posted at

はじめに

docker-compose.yml の version 3 でホストOSのディレクトリを共有する場合、下記の設定で行う解説を見かけますが Windows では動作しません。

volumes:
  sites:
    driver: local
    driver_opts:
      type: none
      device: /path/to/host
      o: bind

Docker の公式リファレンスに理由が記述されていました。
docker volume create | Docker Documentation

The built-in local driver on Windows does not support any options.

解決方法

ボリュームコンテナを使えばこれまで通りディレクトリ共有が可能です。
下の例では base でマッピングされた /dataweb が参照しています。

version: "3.4"
services:
  base:
    build:
      context: ./base
    image: takaya030/base:1.0
    volumes:
      - ./data:/data
  web:
    build:
      context: ./web
    image: takaya030/web:1.0
    volumes:
      - base:/data

volumes:
  base:

参考

Docker Compose Mounting Volume Error: No Such File or Directory - Stack Overflow

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