Compose: b'OCI runtime create failed with read-only volumes

Created on 14 Mar 2019  路  3Comments  路  Source: docker/compose

Description of the issue

There is some weird issue happens if any of volume magento is read-only. I didn't find any proper way to make this work currently.

Context information (for bug reports)

Output of docker-compose version

docker-compose version 1.23.2, build 1110ad01
docker-py version: 3.6.0
CPython version: 3.6.6
OpenSSL version: OpenSSL 1.1.0h  27 Mar 2018

Output of docker version

Client: Docker Engine - Community
 Version:           18.09.2
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        6247962
 Built:             Sun Feb 10 04:12:39 2019
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       6247962
  Built:            Sun Feb 10 04:13:06 2019
  OS/Arch:          linux/amd64
  Experimental:     true

Output of docker-compose config
(Make sure to add the relevant -f and other flags)

version: '2'
services:
  fpm:
    image: 'magento/magento-cloud-docker-php:7.1-fpm'
    ports:
      - 9000
    links:
      - db
    volumes:
      - 'magento:/var/www/magento:ro'
    volumes_from:
      - appdata
  db:
    image: 'mariadb:10.2'
    ports:
      - 3306
    volumes:
      - /var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=magento2
      - MYSQL_DATABASE=magento2
      - MYSQL_USER=magento2
      - MYSQL_PASSWORD=magento2
  web:
    image: 'magento/magento-cloud-docker-nginx:latest'
    ports:
      - '8030:80'
    links:
      - fpm
      - db
    volumes:
      - 'magento:/var/www/magento:ro'
    volumes_from:
      - appdata
  build:
    image: 'magento/magento-cloud-docker-php:7.1-cli'
    hostname: build.magento2.docker
    container_name: build
    depends_on:
      - db
    volumes:
      - '~/.composer/cache:/root/.composer/cache'
      - 'magento:/var/www/magento:rw'
    volumes_from:
      - appdata
  deploy:
    image: 'magento/magento-cloud-docker-php:7.1-cli'
    hostname: deploy.magento2.docker
    container_name: deploy
    depends_on:
      - db
    volumes:
      - '~/.composer/cache:/root/.composer/cache'
      - 'magento:/var/www/magento:ro'
    volumes_from:
      - appdata
  cron:
    image: 'magento/magento-cloud-docker-php:7.1-cli'
    hostname: cron.magento2.docker
    container_name: cron
    depends_on:
      - db
    volumes:
      - '~/.composer/cache:/root/.composer/cache'
      - 'magento:/var/www/magento:ro'
    volumes_from:
      - appdata
    command: run-cron
  appdata:
    image: tianon/true
    volumes:
      - '.:/var/www/ece-tools'
      - /var/www/magento/pub/static
      - /var/www/magento/pub/media
      - /var/www/magento/var
      - /var/www/magento/app/etc
volumes:
  magento: {  }

Steps to reproduce the issue

  1. Run docker-compose up -d

Observed result

  • Errors
ERROR: for cron  Cannot start service cron: b'OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \\"rootfs_linux.go:58: mounting \\\\\\"/var/lib/docker/volumes/7d24f15f654301784aa3d664964a971d6927f4d6dc2631b2bd5610ae7546f10f/_data\\\\\\" to rootfs \\\\\\"/var/lib/docker/overlay2/66f4ae310ed45dccdf8dc4367f30d692b467a571618f95192aa20b4ddd905baa/merged\\\\\\" at \\\\\\"/var/lib/docker/overlay2/66f4ae310ed45dccdf8dc4367f30d692b467a571618Creating deploy              ... error
/var/www/magento/var: read-only file system\\\\\\"\\"": unknown'

Expected result

  • Containers started

Stacktrace / full error message

(paste here)

Additional information

OS version / distribution, docker-compose install method, etc.

Most helpful comment

The end of the original error message is:

error /var/www/magento/var: read-only file system

Since you have mounted /var/www/magento in that container as ro this means that something at runtime tried to create that directory, which will fail on a ro mount. I suspect this is because you're nesting volumes (/var/www/magennto explicitly, and then subvolumes via the use of volumes_from).

When @alexus1024 removed the :ro modifier and reran the mkdir succeeded and then on subsequent runs with :ro the dir already existed because the volume is reused.

So I think the upshot of this is if you want to nest volumes as you are doing here, and you want outer volumes to be ro, then you are responsible for ensuring that any necessary mount points are already present. If not then the mount will need to be writeable.

I'm going to close this issue since I think it isn't a bug, if you need help on using compose then please use the https://forums.docker.com/ or the Docker community Slack channel.

All 3 comments

Same issue, same docker versions
detailed error message from docker-compose up:

ERROR: for <!container name!>  Cannot start service <!container name!>: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"<!host path to volume!>\\\" to rootfs \\\"/var/lib/docker/overlay2/4a9de6f94994e00d10c4a4c281f26c36aa1177894b5dec4b2b82083ae3c3370d/merged\\\" at \\\"/var/lib/docker/overlay2/4a9de6f94994e00d10c4a4c281f26c36aa1177894b5dec4b2b82083ae3c3370d/merged/srv/static/public/layout\\\" caused \\\"mkdir /var/lib/docker/overlay2/4a9de6f94994e00d10c4a4c281f26c36aa1177894b5dec4b2b82083ae3c3370d/merged/srv/static/public/layout: read-only file system\\\"\"": unknown
ERROR: Encountered errors while bringing up the project.

volumes declaration from docker-compose:

volumes:
      - <!host path to working volume!>:/ben/doer-email # it works
      - <!host path to volume!>:/srv/static/public/layout:ro # issue with this volume
      - <!host path to other volume!>:/srv/static/public:ro

removing :ro modifier from volume declaration solves problem

something mystical just happen )
I removed :ro volume modifier, and error disappeared
then I have restored :ro and .... error didn't return.
馃槙
But I think you can try to solve a problem same way.

The end of the original error message is:

error /var/www/magento/var: read-only file system

Since you have mounted /var/www/magento in that container as ro this means that something at runtime tried to create that directory, which will fail on a ro mount. I suspect this is because you're nesting volumes (/var/www/magennto explicitly, and then subvolumes via the use of volumes_from).

When @alexus1024 removed the :ro modifier and reran the mkdir succeeded and then on subsequent runs with :ro the dir already existed because the volume is reused.

So I think the upshot of this is if you want to nest volumes as you are doing here, and you want outer volumes to be ro, then you are responsible for ensuring that any necessary mount points are already present. If not then the mount will need to be writeable.

I'm going to close this issue since I think it isn't a bug, if you need help on using compose then please use the https://forums.docker.com/ or the Docker community Slack channel.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DhairyashilBhosale picture DhairyashilBhosale  路  3Comments

HackerWilson picture HackerWilson  路  3Comments

Hendrik-H picture Hendrik-H  路  3Comments

maltefiala picture maltefiala  路  3Comments

bitver picture bitver  路  3Comments