crops / extsdk-container

A container image that is able to setup and use an extensible sdk generated using openembedded-core.
GNU General Public License v2.0
35 stars 15 forks source link

The uid:gid for "/workdir" is "0:0". The uid and gid must be non-zero. #10

Closed holagvk closed 4 years ago

holagvk commented 4 years ago

Hi,

I am planning to integrate extsdk-container with gitlab-ci, and wrote a basic script just to get the ball moving:

variables:
  SDK_RASPBERRYPI3: /builds/$CI_PROJECT_PATH/SDK/raspberrypi3

before_script:
  - apk add git git-lfs --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/
  - git lfs pull

stages:
  - build

raspberrypi3:
  stage: build
  image: docker:git
  services:
  - docker:dind
  script:
    - docker run -v "$SDK_RASPBERRYPI3:/workdir" crops/extsdk-container --url /workdir/sdk.sh
  when: manual

However, docker run fails with:

[...]
 Status: Downloaded newer image for crops/extsdk-container:latest
 The uid:gid for "/workdir" is "0:0". The uid and gid must be non-zero. Please check to make sure the "volume" or "bind" specified using either "-v" or "--mount" to docker, exists and has a non-zero uid:gid.

I have tried passing in --user explicitly as --user 1000:1000 => but it doesn't solve the problem.

Is it something that needs to be addressed in extsdk-container? My google magic isn't helping out.

holagvk commented 4 years ago

I believe it's because of this commit.

A workaround is to add chown before docker run:

raspberrypi3:
  stage: build
  image: docker:git
  services:
  - docker:dind
  script:
    - chown -R 1000:1000 $SDK_RASPBERRYPI3
    - docker run -v "$SDK_RASPBERRYPI3:/workdir" crops/extsdk-container --url /workdir/sdk.sh
  when: manual
Ricardicus commented 3 years ago

I am trying to set this up on Windows. All mounted volumes get root uid and guid (0) when I mount the volume. The fix mentioned above does not work for Windows. This sanity check is causing me problems.

I would be nice if I could pass the --uid and --gid arguments down from the esdk-entry.py script to the usersetup.py script, I think that would help me.

rewitt1 commented 3 years ago

Hi @Ricardicus,

Could you show the docker command and arguments you are using?

Which mechanism are you using to run on Windows: Docker Toolbox, Docker for Windows, WSL?

Ricardicus commented 3 years ago

I'm running Docker Desktop with WSL2 but no Hyper-V, on Windows 10, 1903. Docker version 19.03.13, build 4484c46d9d.

I do the following:

cd extsdk-container
mkdir sdkdir
# building works fine
docker build -t extsdk:1.0 . 
# here is where I run into trouble
docker run --rm -it -v c:\.......\sdkdir:/workdir extsdk:1.0 --url .......

The output I get is:

The uid:gid for "/workdir" is "0:0". The uid and gid must be non-zero. Please check to make sure the "volume" or "bind" specified using either "-v" or "--mount" to docker, exists and has a non-zero uid:gid.

If I edit the code, remove the sanity check, I get to another problem:

Extracting SDK..................................................................................................tar: .: Cannot utime: Operation not permitted
tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted
tar: Exiting with failure status due to previous errors
Unable to setup sdk.

That can, however, have something to do with our setup script. But I am not sure.

Thank you!

rewitt1 commented 3 years ago

@Ricardicus

I was able to get WSL with docker working. The summary would be

  1. Run docker from a WSL prompt instead of from the Windows host
  2. Use the storage inside of WSL instead of the NTFS filesystem that exists on the host
  3. Using the filesystem inside of WSL is basically ensuring that it is a Linux filesystem with the support needed for Yocto.

Here is an example of it working for me:

PS C:\Users\User> wsl                                                           
To run a command as administrator (user "root"), use "sudo <command>".          
See "man sudo_root" for details.                                                

user@WinDev2007Eval:/mnt/c/Users/User$ cd /home/user                            
user@WinDev2007Eval:~$ mkdir workdir                                            
user@WinDev2007Eval:~$ docker run --rm -it -v `pwd`/workdir:/workdir crops/extsdk-container --url http://downloads.yoctoproject.org/releases/yocto/yocto-3.1.3/toolchain/x86_64/poky-glibc-x86_64-core-image-minimal-core2-32-qemux86-toolchain-ext-3.1.3.sh
Attempting to download http://downloads.yoctoproject.org/releases/yocto/yocto-3.1.3/toolchain/x86_64/poky-glibc-x86_64-core-image-minimal-core2-32-qemux86-toolchain-ext-3.1.3.sh
######################################################################## 100.0% 
Poky (Yocto Project Reference Distro) Extensible SDK installer version 3.1.3    
============================================================================    
You are about to install the SDK to "/workdir". Proceed [Y/n]? Y                
Extracting SDK...............done                                               
Setting it up...                                                                
Extracting buildtools...                                                        
Preparing build system...                                                       
WARNING: You are running bitbake under WSLv2, this works properly but you should optimize your VHDX file eventually to avoid running out of storage space
Parsing recipes: 100% |###########################################################################################################################################################################################################################################| Time: 0:01:28
Initialising tasks: 100% |########################################################################################################################################################################################################################################| Time: 0:00:01
Loading cache: 100% |#############################################################################################################################################################################################################################################| Time: 0:00:01
Initialising tasks: 100% |########################################################################################################################################################################################################################################| Time: 0:04:15
done                                                                            
SDK has been successfully set up and is ready to be used.                       
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
 $ . /workdir/environment-setup-core2-32-poky-linux                             
SDK environment now set up; additionally you may now run devtool to perform development tasks.
Run devtool --help for further details.                                         
sdkuser@d927fc262738:/workdir$

If you want to see the files that exist inside WSL, you can run the following command from the directory of interest from a WSL prompt user@WinDev2007Eval:~$ explorer.exe .

This is similar to the instructions at https://github.com/crops/docker-win-mac-docs/wiki/Windows-Instructions-%28Docker-Toolbox%29#create-the-samba-container, but instead use the built-in WSL functionality rather than requiring a samba container to be created.

Ricardicus commented 3 years ago

Thank you, that made it work for me also!

craigblaster commented 2 years ago

I am trying to set this up on Windows. All mounted volumes get root uid and guid (0) when I mount the volume. The fix mentioned above does not work for Windows. This sanity check is causing me problems.

I would be nice if I could pass the --uid and --gid arguments down from the esdk-entry.py script to the usersetup.py script, I think that would help me.

I had the same issue. I managed to resolve it by running another container (ubuntu) on the image and chown'ing the workdir to 1001:1001

docker run --rm -it -v myvolume:/workdir ubuntu /bin/bash
# chown 1001:1001 -R /workdir