docker unable to create mount path and fails always

Viewed 689

docker unable to create mount path /foo/logs, which is being shared across all containers in my docker-compose file. This error happens occasionally and not sure what is causing this. We have to restart docker or the machine to get around this problem now on the latest version of docker-compose

volumes:
  - /foo/logs:/app/service/logs

docker-compose -f docker-compose.yaml --env-file=.env.qa up -d

Starting foo-service-container ... error

ERROR: for foo-service-container  Cannot start service foo-service: error while creating mount source path '/foo/logs': mkdir /foo: read-only file system

ERROR: for foo-service  Cannot start service foo-service: error while creating mount source path '/foo/logs': mkdir /foo: read-only file system

Various containers have their respective volume setting as follows, so all container logs are spooled to a single location in a machine. Not sure how to make this robust

  - /foo/logs:/app/foo-service/logs
  - /foo/logs:/app/foo-service1/logs
  - /foo/logs:/app/foo-service2/logs
  - /foo/logs:/app/foo-service3/logs
  - /foo/logs:/app/foo-service4/logs
2 Answers

It seems that the /foo/logs filesystem is mounted as read-only. Use mount | grep "/foo/logs" to check the options for the /foo/logs and re-mount if needed - something like mount -o remount,rw /foo/logs (I'm assuming /foo/logs is not under your root file system).

Also, bind mounts between multiple containers might result in issues. Ownership of files might become messy - use volumes instead.

Docker is trying to create a directory that will then be mounted into the containers.

If you try to create the directory by yourself, ie mkdir /foo/logs you'll get a similar error.

This is unrelated to Docker and the problem resides in your permissions on that specific path.

Isolate the issue from Docker by changing all source paths (the part before the :) to a directory on which you have write access, for example /tmp/foo.

Note the issue is not with /foo/logs but with /foo, as the message says it can not create /foo in a read-only system; it did not even reach the point of creating logs inside /foo.

Related