Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use volumes with docker-compose #6

Closed
stereobooster opened this issue Apr 14, 2019 · 21 comments
Closed

Can't use volumes with docker-compose #6

stereobooster opened this issue Apr 14, 2019 · 21 comments

Comments

@stereobooster
Copy link

stereobooster commented Apr 14, 2019

docker-compose.yml

version: "3"

services:
  web:
    image: agentejo/cockpit
    ports:
      - "8080:80"
    restart: always
    volumes:
      - ./db/storage/:/var/www/html/storage
      - ./db/config/:/var/www/html/config

Run

docker-compose up

Open http://localhost:8080/install/ and get

Data folder is not writable: /storage/data
Cache folder is not writable: /storage/cache
Temp folder is not writable: /storage/tmp
Uploads folder is not writable: /storage/uploads

https://github.com/stereobooster/headless-cms-comparison/tree/master/cockpit

@ufoscout
Copy link

ufoscout commented May 3, 2019

Any update on this?
My company is evaluating cockpit and this is a blocker for us.

@aheinze
Copy link
Member

aheinze commented May 3, 2019

my solution to this is to create a custom container-entrypoint.sh with the following contents:

#!/bin/sh

mkdir -p /var/www/html/storage/data
mkdir -p /var/www/html/storage/uploads
mkdir -p /var/www/html/storage/cache
mkdir -p /var/www/html/storage/thumbs
mkdir -p /var/www/html/storage/tmp

chown -R www-data:www-data /var/www/html/

exec $@

and then in the docker file use the file as the entry point:

ADD container-entrypoint.sh /
ENTRYPOINT ["/container-entrypoint.sh"]

@hilyin
Copy link

hilyin commented Nov 14, 2019

I am stuck on this also. What is weird, is locally on OSX docker, it works fine. But on ubuntu 18 docker, I get this issue:

image

I found that when I bash into the container and look at the perms etc, it looks incorrect on the storage folder.

root@b37007a283b7:/var/www/html# ls -lah
total 100K
drwxrwxrwx 1 www-data www-data 4.0K Sep 26 21:15 .
drwxr-xr-x 1 root     root     4.0K Jun 27 23:31 ..
-rw-r--r-- 1 www-data www-data 6.1K Sep 26 21:15 .htaccess
-rw-r--r-- 1 www-data www-data 4.4K Sep 25 21:40 CONTRIBUTING.md
-rw-r--r-- 1 www-data www-data  746 Sep 25 21:40 Dockerfile
-rw-r--r-- 1 www-data www-data 1.2K Sep 25 21:40 LICENSE
-rw-r--r-- 1 www-data www-data 2.2K Sep 25 21:40 README.md
drwxr-xr-x 1 www-data www-data 4.0K Sep 25 21:40 addons
drwxr-xr-x 1 www-data www-data 4.0K Sep 25 21:40 assets
-rw-r--r-- 1 www-data www-data  12K Sep 25 21:40 bootstrap.php
-rw-r--r-- 1 www-data www-data  898 Sep 25 21:40 composer.json
drwxr-xr-x 2 www-data www-data 4.0K Nov 14 06:38 config
-rwxr-xr-x 1 www-data www-data  783 Sep 25 21:40 cp
-rw-r--r-- 1 www-data www-data   24 Aug 23  2017 defines.php
-rw-r--r-- 1 www-data www-data 3.7K Sep 25 21:40 favicon.png
-rw-r--r-- 1 www-data www-data 1.8K Sep 25 21:40 index.php
drwxr-xr-x 1 www-data www-data 4.0K Sep 25 21:40 install
drwxr-xr-x 1 www-data www-data 4.0K Sep 25 21:40 lib
drwxr-xr-x 1 www-data www-data 4.0K Sep 25 21:40 modules
-rw-r--r-- 1 www-data www-data 1.2K Sep 25 21:40 package.json
drwxr-xr-x 8     1000 staff    4.0K Nov 14 00:31 storage

I did a chown -R www-data:www-data storage/ and it fixed it... unsure if its a permanent fix though.

edit: Its not permanent. Whenever I rsync my storage directory from osx host to ubuntu host, it gets incorrect user:group and needs to be fixed.

Right now I do this:
docker exec -it <container-id> chown -R www-data:www-data storage

edit again:

Ok I found the solution for my situation is to add to my up.sh script that starts docker-compose to do a sudo chown -R www-data:www-data storage on that storage folder before it calls docker-compose up

@tommueller
Copy link

I also ran into this issue. Could the suggestions proposed by @aheinze not be added to the official dockerfile?

@cupcakearmy
Copy link
Contributor

fixed it in this pr #12

@cupcakearmy
Copy link
Contributor

@stereobooster test it now with the pr merged. If so you can close the issue :)

@tommueller
Copy link

Fixed it for me. Thx @cupcakearmy && @aheinze !

@BlindDespair
Copy link

@cupcakearmy still not working for me. Getiing this error:
Screenshot from 2020-01-17 00-33-45
Screenshot from 2020-01-17 00-35-40

I tried just using docker-compose.yml file from the original Issue message. Also I tried clonning repository and building image locally, the issue stays the same. Any idea?

@cupcakearmy
Copy link
Contributor

Is it a clean system or an existing one?

@cupcakearmy
Copy link
Contributor

@BlindDespair have you tried these steps?

#12 (comment)

@BlindDespair
Copy link

BlindDespair commented Jan 17, 2020

@cupcakearmy both me and my friend tried it. My system was not completely clean, because I already had cockpit running before although it was just couple of weeks. But my friend yesterday did it on completely fresh system and had the same issue.

I tried the steps you mentioned there. I checked out the repository, built a docker image with docker-compose and then tried running but still same problem...

The only difference was that the version of my docker-compose file was only 3. When I try 3.7 I get error that it's an invalid version.

@cupcakearmy
Copy link
Contributor

if 3.7 is an invalid version you should update docker & docker-compose first. maybe there is the error?

@cupcakearmy
Copy link
Contributor

i don't know what else could be the issue

@BlindDespair
Copy link

@cupcakearmy Thank you for fast responses. I will check my version today in the evening. But I installed docker and docker-compose recently with apt-get on ubuntu, I think it should be already one of the most recent. But if it turns out to be the case, I think still won't completely be okay if I can't just install docker by default and use it that way.
Anyway I will let you know if I find out anything.

@cupcakearmy
Copy link
Contributor

Have you added the docker repository or have you just apt install docker because that installs a super old verison. you need docker-ce

@cupcakearmy
Copy link
Contributor

If you haven't follow these instructions https://docs.docker.com/install/linux/docker-ce/ubuntu/

@BlindDespair
Copy link

@cupcakearmy thank you again for your answers very much. I don't remember now how exactly I installed I think I had to add something. But I will check in the evening again, it could be that I did it wrong actually.

@BlindDespair
Copy link

BlindDespair commented Jan 17, 2020

@cupcakearmy I can confirm that it works when I checkout the project and build image myself. However when I run it using proper docker-compose.yml file using image from registry it seems like entrypoint is just not running for me or not doing anything.
Here is my docker-compose.yml:

version: "3.7"

services:
  web:
    image: agentejo/cockpit
    ports:
      - "8080:80"
    volumes:
      - ./db/storage/:/var/www/html/storage
      - ./db/config/:/var/www/html/config

when I do ls -l on db folder I see root as the only owner on it and on the folders inside it too. However when I check permissions in checked out cockpit-docker with locally build image I have only root as owner on db folder but I have www-data as owner on config and storage which is why it works.
Now what I don't get is why does it behave differently?

EDIT:
when I try running the container with just docker run -v ... -d --name cockpit -p 8080:80 agentejo/cockpit I still have the same problem, which means it's not only docker-compose.

@BlindDespair
Copy link

Ok, I figured out finally what happened here and why it was different. Apparently I had cockpit pulled before your fix. And somehow even despite me writing :latest in some tries it would always use the image that was already pulled, so basically it was just cached. I removed the image locally and then triggered another build, it pulled new image and it finally works! I can confirm that it's working.

@cupcakearmy
Copy link
Contributor

yes, you need to do a docker-compose pull otherwise the local latest tag ist not updated :)

@stereobooster
Copy link
Author

Thanks for the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants