Docker for Windowsでのvolumeマウント問題にぶち当たっている
Docker for mac では動くのに Docker for Windows では動かない件について
Dockerを使い始めて数か月がたつが、Docker for macでは動くのにDocker for Windowsではエラーをはいてコンテナが停止するようなものが何件かある。 そのほとんどが、volumeのマウントに関してだ。
postgresやmysqlのデータ永続化のために、ホストにマウントする際にエラーが起こる 例えば、このようなdocker-composeを起動するとする(Redmineサーバの立ち上げ)
version: '2' services: redmine: image: redmine ports: - 8080:3000 environment: REDMINE_DB_MYSQL: db REDMINE_DB_PASSWORD: example volumes: - ./redmine-data/redmine:/usr/src/redmine/files depends_on: - db restart: always db: image: mysql command: mysqld --character-set-server=utf8 --collation-server=utf8_unicode_ci environment: MYSQL_ROOT_PASSWORD: example MYSQL_DATABASE: redmine_db volumes: - ./redmine-data/db:/var/lib/mysql restart: always
これがとにかく意味不明なログをはいて止まる。 Macだと問題なく動くのにWindowsだと止まってしまう
こちらも止まる
FROM kyobad/anaconda3-alpine MAINTAINER K.Kato RUN conda install -y seaborn psycopg2 networkx\ && pip install chainer \ && conda install -y -c https://conda.anaconda.org/andrewannex spiceypy WORKDIR /root/notebook CMD ["/bin/sh", "-c", "jupyter notebook --no-browser --port=8888 --ip=0.0.0.0"]
version: '2' services: db: image: postgres restart: always environment: POSTGRES_USER: pythonist POSTGRES_PASSWORD: password POSTGRES_DB: mypyenv ports: - "5432" container_name: postgres-db volumes: - ./postgres-db:/var/lib/postgresql/data - ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d python: build: . volumes: - ./workdir:/root/notebook/ ports: - "8888:8888" links: - db depends_on: - db
こちらはownerが違うと怒られる。
postgres-db | HINT: The server must be started by the user that owns the data directory. postgres-db | FATAL: data directory "/var/lib/postgresql/data" has wrong ownership postgres-db | HINT: The server must be started by the user that owns the data directory. postgres-db | FATAL: data directory "/var/lib/postgresql/data" has wrong ownership postgres-db | HINT: The server must be started by the user that owns the data directory. postgres-db | FATAL: data directory "/var/lib/postgresql/data" has wrong ownership postgres-db | HINT: The server must be started by the user that owns the data directory. postgres-db exited with code 1
ほかにも、Permission deniedであったり、httpsがどうのこうのみたいなエラーをはいて止まったり、 Macで問題なく動くものがWindowsでは動かないという現象が多々見られる。 githubのissueにもこれらのことが結構上がったりしているみたいなので、まだ改善はされてない...? github.com
現状、Dockerで困りたくないならMac使ったほうが無難なのかな...