Skip to content
This repository has been archived by the owner on Jun 23, 2021. It is now read-only.

Add user to generated docker image #35

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

clangenb
Copy link

The docker_build.sh script takes into account the current user executing the build and adds the user to the generated docker image. The docker is started by default with that user's USER_ID and GROUP_ID.

This fixes the permission issues for docker generated files on the host system.

Note: the build needs to be executed locally to work. This will not work for the images on dockerhub

@clangenb clangenb changed the title Add user do generated docker image Add user to generated docker image Dec 10, 2020
@brenzi
Copy link
Collaborator

brenzi commented Dec 10, 2020

@electronix can you have a look?

I think this should be separate from the dockerhub stream because of the incompatibility. But then we need to update tutorials in the book

Copy link
Contributor

@electronix electronix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works fine if you build the docker image yourself (why do you need this?). This does not work anymore if you provide the docker image for general purpose or use it on a different machine as the GUID will change.
For fixing the file permissions, look at the cleanup section of https://www.substratee.com/howto_private_tx.html

The following command mounts the current directory into docker and publishes the default ports of the binaries to the host:

```
docker run -it --mount "type=bind,src=$(pwd),dst=/opt/shared" --workdir /opt/shared -p 9979:9944 -p 2079:2000 -p 3079:3443 scssubstratee/substratee_dev:1804-2.12-1.1.3-001-user-1000-group-1000 /bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name of the docker image may be wrong. your user and group can have a different guid

docker run -it --mount "type=bind,src=$(pwd),dst=/opt/shared" --workdir /opt/shared -p 9979:9944 -p 2079:2000 -p 3079:3443 scssubstratee/substratee_dev:1804-2.12-1.1.3-001-user-1000-group-1000 /bin/bash
```

Pre-built docker images are also available on [docker hub](https://hub.docker.com/repository/docker/scssubstratee/substratee_dev/tags). **Note:** The pre-built images will always run as root. Any files generated withing docker can only be changed with root access.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the last sentence is not correct. Please have a look at the cleanup section on howto_private_tx on substratee.com

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ups. I have never seen this section. What about files that are modified by both, like the Cargo.lock? And after subsequent builds. Do we need to return the ownership after every build inside the docker?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you just need to return ownership before exiting the docker container. root can anyhow write your (local) files

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I see that, but my scenario is that I am developping while running the container.

Christian Langenbacher added 2 commits May 31, 2021 13:32
…ing the build and adds the user to the generated docker image. The docker is started by default with that user's USER_ID and GROUP_ID.

This fixes the permission issues for docker generated files.

**Note: ** the build needs to be executed locally to work.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants