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

Docker - failed to open stream permission denied #58

Open
dschmag opened this issue Aug 26, 2021 · 4 comments
Open

Docker - failed to open stream permission denied #58

dschmag opened this issue Aug 26, 2021 · 4 comments

Comments

@dschmag
Copy link

dschmag commented Aug 26, 2021

I tried docker-compose-viz

$ docker run --rm -it --name dcv -v $(pwd):/input pmsipilot/docker-compose-viz render -m image docker-compose.yml
Warning: file_put_contents(/input/docker-compose.png): failed to open stream: Permission denied in /dcv/src/application.php on line 138
Linux myserver 5.4.0-77-generic #86-Ubuntu SMP Thu Jun 17 02:35:03 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Docker version 20.10.7, build 20.10.7-0ubuntu1~20.04.1
@rahedges
Copy link

rahedges commented Dec 5, 2022

I am having this issue too. Any ideas on how to fix this?

@rahedges
Copy link

rahedges commented Dec 5, 2022

This issue is caused by different user ids on the host and in the container. Some user manipulation at the command line might work.

A quick work around is to create an empty output file, set the permissions to match the user in the container and then force-write the generated image over the dummy image.

  1. Run the container and list the id of the user in the container:
docker run --rm -it --name dcv pmsipilot/docker-compose-viz id
uid=1000(dcv) gid=1000(dcv) groups=1000(dcv)
  1. On the host, create an empty file with the name of the output
touch docker-compose.png
  1. Change the owner of the empty output file to match the docker uid and gid found above (1000:1000)
sudo chown 1000:1000 docker-compose.png
  1. Run the container and generate the image as in the original post, but add the --force option to allow the container to overwrite the empty file.
 docker run --rm -it --name dcv -v $(pwd):/input pmsipilot/docker-compose-viz  render -m image --force  docker-compose.yml

@umer936
Copy link

umer936 commented Mar 14, 2023

I fixed this by just giving write permissions to the entire project folder

@Tazoeur
Copy link

Tazoeur commented Apr 24, 2024

another workaround that is a bit cleaner IMHO: run the container with the --user option

docker run --rm -it --user $UID:$GID --name dcv -v "$(pwd):/input" pmsipilot/docker-compose-viz render -m image docker-compose.yml 

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

4 participants