Marko Marjanovic
Marko Marjanovic

Reputation: 506

Docker compose error while creating mount source path

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: {  }

Upvotes: 37

Views: 118299

Answers (5)

HyperionX
HyperionX

Reputation: 1646

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.

Upvotes: 76

Nagev
Nagev

Reputation: 13207

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.

Upvotes: 2

Saditha Udayanga
Saditha Udayanga

Reputation: 382

Restart your docker service. Then the problem will solve.

sudo systemctl restart docker

Upvotes: 23

Konstantin Grigorov
Konstantin Grigorov

Reputation: 1602

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.

Upvotes: 2

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.

Upvotes: 0

Related Questions