Hello,
I am using docker-compose to create my containers. It alls works fine but I realised that one of the volume I created must be owned by www-data:www-data rather than root for the application to work.
I thought I could use “command” in the docker file to do it but when I use it the app doesn’t want to start. Strangely I can see that the command is successful since the ownership of the volume is changed.
your app has a command as chown ....
So your app just will change the file rights and after that exits.
So it behaves as specified.
You should try to start the webserver within the app-command.
This webserver process hopefully will never exit, so docker-compose up -d also will not complain about the exit.
PS: it is also a good practice to add a restart policy like restart: unless-stopped. This will restart everything even if your app will eventually crash sometime.
Hello @think,
I have tried to go that line. I actually retrieved the docker file that the sonerezh project is using to create their image and tried to put the chmod command in on the RUN command but somehow it is still not changing the ownership. The container now stays up at least.
What I found though is that only the _data is updated. Inside _data it is still owned by root… I have reported an issue about that on the github page of the project.
Yes it does work (as in the container does start and stay up) but the problem is that application try to write in that directory and since it is nginx it is using www-data and so it can’t because the directory belongs to root
you do not provide the container the user it should use, so the container just could run as root.
if you want the container to run as www-data (or another user) you need to explicitly tell this to the container.
If the container itself creates a user www-data, then this user has another Id as the www-data user on your host and it will not work.
I am not sure I understand you! The container seems to work properly and the music application is a web app that runs as www-data inside the container.
The only issue I have is that it can’t write in that directory and I have not managed to change its ownership
I have actually progressed a bit. I created a directory in that volume and the Dockerfile then create the symbolic link to that directory. I can then change that directory. I am still trying to understand what is going on here!!!