38

I have created a docker-compose.yml using cloudestuary. After downloading it and putting it in my Laravel project folder and running docker-compose up -d the download takes place and then I get this message:

ERROR: for worker-1 Cannot start service worker-1: error while creating mount source path '/var/www/html/lensin/html': mkdir /var/www: read-only file system

ERROR: for nginx Cannot start service nginx: error while creating mount source path '/var/www/html/lensin/html': mkdir /var/www: read-only file system

ERROR: for app Cannot start service app: error while creating mount source path '/var/www/html/lensin/html': mkdir /var/www: read-only file system

ERROR: for workspace Cannot start service workspace: error while creating mount source path '/var/www/html/lensin/html': mkdir /var/www: read-only file system ERROR: Encountered errors while bringing up the project.

I`m on Ubuntu 17, and have tried even to set 777 to all folders, and running it with sudo, but the result is the same. I have also tried to move the file and to edit the volumes in yml.

Here is my docker compose file:

version: '2'
services:
    nginx:
        image: 'cloudestuary/nginx:mainline-fpm'
        restart: always
        environment:
            CLIENT_MAX_BODY_SIZE: 100m
            DOCUMENT_ROOT: /var/www/html/public
            INDEX_FILE: index.php
            PHP_FPM: app
        networks:
            - app
        volumes:
            - './html:/var/www/html'
        ports:
            - '80:80'
    app:
        image: 'cloudestuary/php-fpm:7.1'
        restart: always
        environment:
            MAX_UPLOAD_FILE_SIZE: 100m
            APP_URL: 'http://lensin.localhost'
            APP_KEY: 'base64:2X9U1HiBdmfbwvZ4UkwUP/25svg7439HXKWL1F8Xn1c='
            DB_CONNECTION: mysql
            DB_HOST: mysql
            DB_PORT: '3306'
            DB_DATABASE: cloudestuary
            DB_USER: cloudestuary
            DB_PASSWORD: secret
        networks:
            - app
        volumes:
            - './html:/var/www/html'
    workspace:
        image: 'cloudestuary/php-workspace:7.1'
        restart: always
        ports:
            - '2222:22'
        environment:
            MAX_UPLOAD_FILE_SIZE: 100m
            APP_URL: 'http://lensin.localhost'
            APP_KEY: 'base64:2X9U1HiBdmfbwvZ4UkwUP/25svg7439HXKWL1F8Xn1c='
            DB_CONNECTION: mysql
            DB_HOST: mysql
            DB_PORT: '3306'
            DB_DATABASE: cloudestuary
            DB_USER: cloudestuary
            DB_PASSWORD: secret
            SSH_PASSWORD: xsKEVWXPrdAeg
        networks:
            - app
        volumes:
            - './html:/var/www/html'
    worker-1:
        image: 'cloudestuary/php-cli:7.1'
        restart: always
        networks:
            - app
        environment: {  }
        volumes:
            - './html:/var/www/html'
        command: 'php artisan queue:work'
    mysql:
        image: 'mysql:5.7'
        restart: always
        networks:
            - app
        environment:
            MYSQL_ROOT_PASSWORD: toor
            MYSQL_PASSWORD: secret
            MYSQL_USER: cloudestuary
            MYSQL_DATABASE: cloudestuary
        volumes:
            - 'mysql-data:/var/lib/mysql'
volumes:
    mysql-data: {  }
networks:
    app: {  }
3
  • Looking for read-only file system error in docker might help Commented Aug 19, 2017 at 6:43
  • Check if using volume-nocopy helps or not Commented Aug 19, 2017 at 6:45
  • Error creating aufs mount: read only file system looks similar to your issue Commented Aug 19, 2017 at 6:49

5 Answers 5

82

It's likely a pathing issue with Docker when installed with snap, you're better off installing it with the official documentation from Docker.

Remove docker from snap

snap remove docker

Remove the docker directory, and old version (It's okay if these don't exist already)

rm -R /var/lib/docker

sudo apt-get remove docker docker-engine docker.io

Install the official docker package: https://docs.docker.com/install/linux/docker-ce/ubuntu/

Update: Since posting this answer, I've learnt that tools installed using snap are installed in a sandbox with limited permissions outside of that sandbox. This is likely the cause as docker won't have access to the external filesystem from its isolated sandbox environment.

Sign up to request clarification or add additional context in comments.

3 Comments

This mysterious answer worked for me. Use snap remove --purge docker to skip saving the previous snapshot because that can take a long time.
Silly Ubuntu includes snap installed Docker by default (when using installer it installs that)
When I removed the Docker, I accidentally removed something that also relied on the Docker that I was not aware of. The unexpected snapshot saved my day, although it took me about two hours.
23

Restart your docker service. Then the problem will solve.

sudo systemctl restart docker

2 Comments

in case of snap you have to snap restart docker to restart docker service. But it does not worked for me. Looks like snap has some permission problem with the path I wanted to use as volume. changed to another path and it worked.
In my case, I deleted a project before running a docker-composer down. Then I ran the docker-composer up command in a fork of the original repository (after recreating the directory). Seems that Docker didn't like it. It was OK after a docker system prune and restart.
2

What led me here was the Kubernetes V1VolumeMount. When deploying my application I was getting the same error format:

ERROR: for <pod_name> Cannot start <service_name>: error while creating mount source path '<source_path>': mkdir <dir_path>: read-only file system

At the start I was thinking permissions error as well, hence the message is a bit misleading. I turned out that I was trying to mount something that didn't exist in the source image. Hence, my uneducated suggestion would be, verify that what you are trying to mount does exist, if it doesn't you probably don't need that mount path.

P.S. I saw that there wasn't an accepted answer, so I am hoping that my contribution is not causing unnecessary cluttering.

Comments

2

Got this error but the issue was that the source path was a symlink. For some reason docker does not seem to like it, even after restarting the service.

Had to use a real path and then it worked just fine with Docker version 20.10.8 installed with snap.

Comments

0

For Docker on Windows 10, sometimes you have just to wait a while (1-5 min) before executing docker-compose up again.

Hope this will help someone else.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.