genuinetools / img

Standalone, daemon-less, unprivileged Dockerfile and OCI compatible container image builder.
https://blog.jessfraz.com/post/building-container-images-securely-on-kubernetes/
MIT License
3.89k stars 230 forks source link

Getting "nsenter: USER is unset: Inappropriate ioctl for device" error trying to run img on Ubuntu 16.04 #254

Open othomann opened 5 years ago

othomann commented 5 years ago

Hi, I installed img 0.5.7 on top of Ubuntu with the required packages as root. uname -a returns:

Linux 82b577ed1adb 4.4.0-154-generic #181-Ubuntu SMP Tue Jun 25 05:29:03 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

here is my script:

#!/bin/bash
export IMG_DISABLE_EMBEDDED_RUNC=1
apt-get update
apt-get install uidmap libseccomp-dev
chmod 4755 /usr/bin/newuidmap

echo "root:100000:65536" > /etc/subgid
echo "root:100000:65536" > /etc/subuid

echo "Downloading img"
curl -fSL -o /usr/local/bin/img https://github.com/genuinetools/img/releases/download/v0.5.7/img-linux-amd64
curl -fSL https://github.com/genuinetools/img/releases/download/v0.5.7/img-linux-amd64.sha256 -o /usr/local/bin/img-linux-amd64.sha256
echo "Checking download hash"
echo "`cat /usr/local/bin/img-linux-amd64.sha256 | awk '{print $1}'` /usr/local/bin/img" | sha256sum -c -
echo "Installing img"
chmod a+x /usr/local/bin/img
img build -t test:latest -f Dockerfile .

Unfortunately I always get this error nsenter: USER is unset: Inappropriate ioctl for device. I tried to search for a solution, but I didn't find anything useful. Any idea what could be wrong?

Thanks for any pointers you might have.

issue-label-bot[bot] commented 5 years ago

Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.

othomann commented 5 years ago

note that if I do: img version, it works.

Justin-DynamicD commented 3 years ago

Were you ever able to solve this? I'm running into the same issue, with the same error, only difference is I've stepped up to 0.5.11

jijeshvu07 commented 1 year ago
  sh '''
                           sudo apt-get update -y \\
                        && sudo apt-get install -y uidmap \\
                        && echo "Downloading img" \\
                        && curl -fSL "https://github.com/genuinetools/img/releases/download/v0.5.11/img-linux-amd64" -o "/usr/local/bin/img" \\
                        && echo "cc9bf08794353ef57b400d32cd1065765253166b0a09fba360d927cfbd158088  /usr/local/bin/img" | sha256sum -c - \\
                        && chmod a+x "/usr/local/bin/img"
                        '''
                        sh 'img -v'
                        echo "img installed!"

I can install the img, but on building image throwing same error, any update on this?

jijeshvu07 commented 1 year ago

got the fix

  sudo apt-get update -y \\
                            && sudo apt-get install -y uidmap \\
                            && sudo apt-get install -y qemu-user-static \\
                            && echo "Downloading img" \\
                            && curl -fSL "https://github.com/genuinetools/img/releases/download/v0.5.11/img-linux-amd64" -o "/usr/local/bin/img" \\
                            && echo "cc9bf08794353ef57b400d32cd1065765253166b0a09fba360d927cfbd158088  /usr/local/bin/img" | sha256sum -c - \\
                            && chmod a+x "/usr/local/bin/img"

Also configured the environment for Jenkins pipeline.

 environment {
                USER = "jenkins"
            }