0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Docker】Error response from daemon: invalid mount config for type "volume": invalid mount path: 'myapp' mount path must be absoluteの対処法

Posted at

症状

Docker compose upを実行したとき、下記のエラーが発生しました。 翻訳すると、「デーモンからのエラー応答: タイプ「ボリューム」のマウント構成が無効です: マウント パスが無効です: 'myapp' マウント パスは絶対パスである必要があります」 つまり、volumeのパスがよくないといわれているようです。
error
 docker compose up           
[+] Running 3/4
 - Network neareats_default    Created                                                                                                                   0.8s 
 - Container neareats-front-1  Created                                                                                                                   0.1s
 - Container neareats-db-1     Created                                                                                                                   0.1s 
 - Container neareats-api-1    Creating                                                                                                                  0.1s 
Error response from daemon: invalid mount config for type "volume": invalid mount path: 'neareats' mount path must be absolute

docker-composeの該当の箇所のみを抜粋したものが以下です。

docker-compose.yml
 api:
    build:
      context: .
      dockerfile: Dockerfile
    command: /bin/sh -c "rm -f /myapp/tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
    image: rails:dev
    volumes:
      - ./myapp
      - ./vendor/bundle:/myapp/vendor/bundle
    environment:
      TZ: Asia/Tokyo
      RAILS_ENV: development
    ports:
      - 3001:3000
    depends_on:
      - db

解決策

volumeの箇所を以下のように変更することで動作しました。 volumeは「ホスト側の相対Path]:コンテナの絶対Path」で指定するので、どちらかしか指定していない状態だよっていう鰓0を返してきてくれていたようです。
docekercompose.yml
 api:
    build:
      context: .
      dockerfile: Dockerfile
    command: /bin/sh -c "rm -f /myapp/tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
    image: rails:dev
    volumes:
      - .:/myapp  #ここ変更しました
      - ./vendor/bundle:/myapp/vendor/bundle
    environment:
      TZ: Asia/Tokyo
      RAILS_ENV: development
    ports:
      - 3001:3000
    depends_on:
      - db

参考

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?