Open arielelkin opened 7 years ago
Update:
We need to add the following line to run.sh to let PHP write to the config directory:
chown www-data:www-data -R /var/www/config
The install wizard will then tell us that ampache.cfg.php is writable!
But at the step where it generates the config file, it’s giving me this error:
Error: Config files not found or unreadable
Basically it can’t find the template ampache.cfg.php… But the dockerfile doesn’t actually install it?
Am I missing something?
I followed your tip above
chown www-data:www-data -R /var/www/config
Then I got the ampache.cfg.php.dist in the repo and manually put it in the config folder. Then the buttons were then set to OK and was able to proceed.
You can check the run.sh file to see that it moved it over. mv /var/temp/ampache.cfg.php.dist /var/www/config/ampache.cfg.php.dist
Then everything seems to install okay.
I't bad idea modify files on host machine from docker.
Instead you need use right UID and GID from host machine in image for www-data user.
Here good example of GID and UID setup for docker-containers - https://docs.linuxserver.io
It sad, but another way to map user rights from host machine to docker volumes are full of pain
--user docker options working bad with volumes
you shouldn't need to do anything special. If you build with your config file it gets copied over from the dockerfile and then copied on run.
Dockerfile
COPY ampache.cfg.* /var/temp/
run.sh
if [[ -f /var/temp/ampache.cfg.php && ! -f /var/www/config/ampache.cfg.php ]]; then
mv /var/temp/ampache.cfg.php /var/www/config/ampache.cfg.php
fi
If you build with your config file it gets copied over from the dockerfile and then copied on run.
This issue is not about custom build of image, it's about launching a image with mounted volume for configs. Even if i build custom docker container with my dist config - the issue still here - i will get not readable config
you shouldn't need to do anything special.
In most host machines docker www-data GID UID not match with HOST machine GID UID - so when image start and copy config we have bad file permissions :man_shrugging:
So i need do many special things to run this image properly.
www-data
docker user for normal file permissions
For now i use special entrypoint for docker-compose
#!/usr/bin/env bash
usermod -a -G users www-data #I't work only for my host machine, you need use groups from yours
exec /run.sh
then my config.php becomes readable
I'll test out what you've said and see what I can do.
This worked fine. test.php comes up all readable.
docker run --name=ampache -d -v /mnt/files-music/albums/:/media:ro -v /var/www/config/:/var/www/config/:rw -p 8888:80 ampache/ampache
Can you check in this example /mnt/files-music/albums/
default file permissions?
/mnt/files-music/albums/
- very similar to SMB mount with default 777 permissions
My point has not changed - on host machine we have user www-data
with different UID then internal docker or host machine have no user www-data
.
You can emulate this with usermod -u 3333 www-data
or just try to mount volume with no www-data
owner - then config been nor readable.
That seems like something that's not an issue with the host not the image.
Can you check in this example
/mnt/files-music/albums/
default file permissions?
/mnt/files-music/albums/
- very similar to SMB mount with default 777 permissionsMy point has not changed - on host machine we have user
www-data
with different UID then internal docker or host machine have no userwww-data
.You can emulate this with
usermod -u 3333 www-data
or just try to mount volume with nowww-data
owner - then config been nor readable.
I second that, the approach in this container works if the music folder is used only by ampache or if all other containers use the same UID and GID, but for configurations with many concurrent services (like mine) maybe is not ideal. Using the USER docker directive it's not useful too because the container use root for the database.
I believe I fixed this. Should be able to specify UID
and GID
environment values in the docker-compose.yml
file. Will set Ampache's internal www-data user to the ID you specify.
@kuzi-moto can you show how to concretely do this?
I will try to remember to do it tomorrow!
I tried adding PGID and PUID in environment section in the docker-compose file. It's the same thing right ? @kuzi-moto because if it is then it didn't work if not then how do I go about this?
EDIT: This is what I did: https://pastebin.com/RKTxP7JN
The warning stays, even though the option seems to work...
I tried adding PGID and PUID in environment section in the docker-compose file. It's the same thing right ? @kuzi-moto because if it is then it didn't work if not then how do I go about this?
EDIT: This is what I did: https://pastebin.com/RKTxP7JN
There is a typo in your file: "enivironment"
@kuzi-moto That works great!
@raaron773 It's PID
and UID
not PGID
and PUID
!
@lachlan-00 I think this can be closed.
@KaeTuuN It's GID and UID
@KaeTuuN It's GID and UID
That's what I wrote!?
I want to persist the Ampache configuration files so that I don't have to reinstall and reconfigure Ampache if docker or the ampache container stop for some reason.
Here's what I do:
Ampache seems to install fine, and then in the Requirements check of the installation wizard, I get this:
But the container does have access to that directory:
Any thoughts?