2
3

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 3 years have passed since last update.

WSL2で、`docker-compose up` したら、shファイルは見当たらないというエラーが出た

Last updated at Posted at 2020-08-27

[追記]
環境構築手順のまとめを Windows 10 Home WSL2でDockerを使う に更新しました


環境

  • WSL2 (windows 10 Home)
  • ubuntu
  • Docker for Windows を使用

手順

docker-compose.yml
services:
  rails:
    <<: *app_base
    shm_size: 2G
    command: bin/start_dev_server.sh

で、 docker-compose up をした。

エラー内容

ERROR: for rails  Cannot start service rails: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"bin/start_dev_server.sh\": stat bin/start_dev_serversh: no such file or directory": unknown

「shファイルが見当たらない/unknown だよ」というエラーが出た。

原因

WSL2では、mnt/cの絶対パスが適用されるが、
Docker for Windows のVMでは、 c の絶対パスが適用されるので、そもそものルートパスが違かったのが原因ぽい。

詳しくは、Docker-compose and incorrect absolute paths for volumes

解決策

$ sudo mkdir /c
$ sudo mount --bind /mnt/c /c
$ cd /c/path/to/project
$ docker-compose ...

Ubuntu上でWindows配下( /mnt/c ) のファイルをmountする

2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?