hoomin.kani

KANISAN WEB

インフラ・サーバーサイドを頑張るカニが学んだあれこれ。

【解決】Dockerの時刻設定、/etc/localtime:/etc/localtime:ro でCannot start service XXX: Mounts denied:のエラー

f:id:hoominkani:20190429125632p:plain

docker-compose upでマウントエラー

現象

以下のような設定のdocker-compose.ymlを使い、docker-compose up -dを行ったところ

volumes:
      - /etc/localtime:/etc/localtime:ro

このようなエラーが出た。

ERROR: for XXX Cannot start service XXX: b'Mounts denied: \r\nThe path /etc/localtime\r\nis not shared from OS X and is not known to Docker.\r\nYou can configure shared paths from Docker -> Preferences... -> File Sharing.\r\nSee https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.\r\n.'
ERROR: Encountered errors while bringing up the project.

解決方法

どうやらenvironmentのようでこのような設定をする必要があるそうだ。

environment:
      - TZ=`ls -la /etc/localtime | cut -d/ -f8-9`

これで無事に動いた。