docker-flutter icon indicating copy to clipboard operation
docker-flutter copied to clipboard

Get rid of chown.sh?

Open matsp opened this issue 4 years ago • 3 comments

Is it possible to improve file permissions?

matsp avatar Jan 06 '21 09:01 matsp

How can we test if its working?

I took out the call to chown.sh in the entrypoint.sh, rebuilt the image (named dockerflutterstable) and called it via

docker run --rm -e UID=$(id -u) -e GID=$(id -g) --workdir /project -v "$PWD":/project dockerflutterstable build apk

or (after a clean)

docker run --rm --workdir /project -v "$PWD":/project dockerflutterstable build apk

and the folders created all belong to my user/group.

My suggestion would have been --user "$(id -u):$(id -g) in something like this

docker run --rm -e UID=$(id -u) -e GID=$(id -g) --workdir /project -v "$PWD":/project --user "$(id -u):$(id -g)" dockerflutterstable build apk

x29a avatar Jan 06 '21 20:01 x29a

I would guess that your local user has also the uid 1000 and gid 1000 that are set at build time. You only set them when you build the image on your own, which is not very user friendly to use this image directly from the hub.

Setting the uid/gid at runtime is for the chown.sh script, to change the ids when they are different than 1000. In most distributions of linux this is the default but not in all.

Using podman instead of docker is fixing this by the way because podman container can only write with the executing user from the host if you have enabled rootless execution.

The --user option could work. For that you should modify the UID and GID of the Dockerfile so that they differ from your host user.

matsp avatar Jan 06 '21 21:01 matsp

I try to improve it along the multistage image changes.

matsp avatar Jan 09 '21 10:01 matsp