13
6

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

「docker-compose up」をしようとしたところ「OCI runtime create failed」

Posted at

DockerでPHPの開発環境を構築していたところエラーが発生

環境

  • macOS mojava(バージョン10.14.4)
  • Docker version 18.09.2

エラーの内容

docker-compose up -d

でコンテナを一斉に立ち上げた際に以下のエラーが発生

Creating php_mysql_nginx_db_1 ... error

ERROR: for php_mysql_nginx_db_1  Cannot start service db: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/Users/UserName/WorkSpace/php_mysql_nginx/mysql/data\\\" to rootfs \\\"/var/lib/docker/overlay2/51d8c0970ffca60b031d04ce28ec8224c6d81ec33635095cc3e2bb6b78cc1a53/merged\\\" at \\\"/var/lib/docker/overlay2/51d8c0970ffca60b031d04ce28ec8224c6d81ec33635095cc3e2bb6b78cc1a53/merged/var/lib/mysql\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

ERROR: for db  Cannot start service db: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/Users/UserUserName/WorkSpace/php_mysql_nginx/mysql/data\\\" to rootfs \\\"/var/lib/docker/overlay2/51d8c0970ffca60b031d04ce28ec8224c6d81ec33635095cc3e2bb6b78cc1a53/merged\\\" at \\\"/var/lib/docker/overlay2/51d8c0970ffca60b031d04ce28ec8224c6d81ec33635095cc3e2bb6b78cc1a53/merged/var/lib/mysql\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: Encountered errors while bringing up the project.

試したこと

1. docker volumeの削除

未使用のvolumeを一括削除

docker volume rm $(docker volume ls -qf dangling=true)

それでもって再度docker-compose up -dを試みるも同じエラー


2. エラーが起きている箇所docker-compose.ymlファイルのdb箇所のvolume部分だからその部分のパスを変える

db:
    image: mysql:5.7
    ports:
      - 13306:3306
    volumes:
      - ./mysql/data:/var/lib/mysql

こうなっていたのを以下のようにしたところ上手くいった!

db:
    image: mysql:5.7
    ports:
      - 13306:3306
    volumes:
      - ./mysql:/var/lib/mysql
13
6
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
13
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?