crops / poky-container

A container image that is able to run bitbake/poky. It has helpers to create users and groups within the container. This is so that the output generated in the container will be readable by the user on the host.
GNU General Public License v2.0
206 stars 94 forks source link

Add a more helpful error message if the workdir is owned by uid/gid 0 #20

Closed rewitt1 closed 4 years ago

rewitt1 commented 6 years ago

Currently if the uid or gid of the workdir are 0, then the user will get a relatively cryptic message

Refusing to use a gid of 0
Traceback (most recent call last):
  File "/usr/bin/usersetup.py", line 62, in <module>
    subprocess.check_call(cmd.split(), stdout=sys.stdout, stderr=sys.stderr)
  File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', 'restrict_groupadd.sh', '0', 'pokyuser']' returned non-zero exit status 1

This should be changed to something more user friendly explaining what may have happened.

In the most common case, the argument passed as --workdir and was bind mounted wasn't yet created before docker starts. For example if the below command was used:

docker run -it --rm -v /foo:/workdir crops/poky --workdir=/workdir

If /foo didn't exist before running docker, then docker will create /foo and give it a uid:gid of 0. While this behavior seems like the wrong action to take, docker chose to preserve it due to reasons of "not breaking workflows".

At that point all the user has to remove the directory docker created, and instead create it manually with the appropriate uid:gid.

Since the "--mount" option to docker will instead error if the directory doesn't exist, then the documentation could be changed to point out the "--mount" option as well. It however, can't be used on older version of docker.

ghost commented 6 years ago

I have the same problem. All issues reference to each other without solving it... What can i do to at least run this container?

rewitt1 commented 4 years ago

Should be addressed by https://github.com/crops/extsdk-container/commit/6e512f007829647351c50722bd4afb8472da7e1a.