gotoz / runq

run regular Docker images in KVM/Qemu
Apache License 2.0
802 stars 45 forks source link

Failed create release image in Ubuntu 22.04 #24

Open zhaohany opened 1 year ago

zhaohany commented 1 year ago

Brief description Below issue from command line while running make release command:


[ 9/11] RUN cp -a --parents /etc/mtab /usr/bin/qemu-system-x86_64 /usr/bin/rsync /usr/lib64/ld-linux-x86-64.so.2 /usr/lib/ipxe/qemu /usr/lib/modules /usr/lib/x86_64-linux-gnu/ceph /usr/lib/x86_64-linux-gnu/qemu /usr/sbin/e2fsck /usr/sbin/fsck.ext2 /usr/sbin/fsck.ext4 /usr/sbin/mke2fs /usr/sbin/mkfs.ext2 /usr/sbin/mkfs.ext4 /usr/share/qemu /usr/share/seabios /var/lib/runq/qemu/: 0.440 cp: cannot stat '/etc/mtab': No such file or directory

When I check, the file exit in file system ls -l /etc/mtab lrwxrwxrwx 1 root root 19 May 17 20:36 /etc/mtab -> ../proc/self/mounts

Steps to reproduce the issue After clone the repo, run: make release

Expected behaviour runq release image created

Actual behaviour ERROR: failed to solve: process "/bin/sh -c cp -a --parents /etc/mtab /usr/bin/qemu-system-x86_64 /usr/bin/rsync /usr/lib64/ld-linux-x86-64.so.2 /usr/lib/ipxe/qemu /usr/lib/modules /usr/lib/x86_64-linux-gnu/ceph /usr/lib/x86_64-linux-gnu/qemu /usr/sbin/e2fsck /usr/sbin/fsck.ext2 /usr/sbin/fsck.ext4 /usr/sbin/mke2fs /usr/sbin/mkfs.ext2 /usr/sbin/mkfs.ext4 /usr/share/qemu /usr/share/seabios $QEMU_ROOT/" did not complete successfully: exit code: 1 make[1]: [Makefile:6: image] Error 1 make[1]: Leaving directory '/home/yzh/runq/qemu' make: [Makefile:27: image] Error 2

Content of section runtimes of /etc/docker/daemon.json

Content of /var/lib/runq/qemu/proxy --version

Content of docker --version Client: Docker Engine - Community Version: 24.0.5

Additional information Operating System: Ubuntu 22.04.2 LTS OSType: linux Architecture: x86_64

pmorjan commented 1 year ago

It looks like you are using the Docker community edition. I can't recreate the issue with the official Docker packages from Ubuntu:

# docker --version
Docker version 20.10.21, build 20.10.21-0ubuntu1~22.04.3

But the community edition fails in this simple example while the Ubuntu version works as expected:

# cat Dockerfile
FROM ubuntu:20.04
RUN cp -a --parents /etc/mtab /tmp/

# docker build -t foo .
...
> [2/2] RUN cp -a /etc/mtab /tmp/:
 15 0.155 cp: cannot stat '/etc/mtab': No such file or directory

Can you please install the official Ubuntu packages and try again ?

apt-get remove  docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
apt-get install docker.io  
zhaohany commented 1 year ago

Thank you @pmorjan for the quick response, the issue resolved after reinstall docker following your instruction.

sammcj commented 9 months ago

Came to log this same bug on Fedora 39.

Is there a reason that the standard docker-ce won't work?

docker-compose-1.29.2-10.fc39.noarch
nvidia-docker2-2.14.0-1.noarch
docker-buildx-plugin-0.12.1-1.fc39.x86_64
docker-ce-cli-25.0.1-1.fc39.x86_64
docker-ce-rootless-extras-25.0.1-1.fc39.x86_64
docker-ce-25.0.1-1.fc39.x86_64
sammcj commented 9 months ago

Found a fix that works!

  1. Update initrd/mkinitrd.sh and add the missing -a to the cp commands.
──────────────────────────────────────────┐
initrd/mkinitrd.sh:14: done < kernel.conf │
──────────────────────────────────────────┘
│ 14 │cp kernel.conf $TMP_DIR/                                              │ 14 │cp kernel.conf $TMP_DIR/
│ 15 │popd >/dev/null                                                       │ 15 │popd >/dev/null
│ 16 │                                                                      │ 16 │
│ 17 │cp $DIR/../cmd/init/init $TMP_DIR/                                    │ 17 │cp -a $DIR/../cmd/init/init $TMP_DIR/
│ 18 │cp $DIR/../cmd/vsockd/vsockd $TMP_DIR/sbin/                           │ 18 │cp -a $DIR/../cmd/vsockd/vsockd $TMP_DIR/sbin/
│ 19 │cp $DIR/../cmd/nsenter/nsenter $TMP_DIR/sbin/                         │ 19 │cp -a $DIR/../cmd/nsenter/nsenter $TMP_DIR/sbin/
│ 20 │cp /usr/bin/docker-init $TMP_DIR/sbin/                                │ 20 │cp -a /usr/bin/docker-init $TMP_DIR/sbin/
│ 21 │                                                                      │ 21 │
│ 22 │pushd $TMP_DIR >/dev/null                                             │ 22 │pushd $TMP_DIR >/dev/null
│ 23 │find . | cpio -o -H newc | gzip > $DIR/initrd                         │ 23 │find . | cpio -o -H newc | gzip > $DIR/initrd
  1. Edit the runq Dockerfile, add a symlink from /proc/mounts to /etc/mtab and replace /etc/mtab from the cp, with the newer style /proc/mounts.
────────────────────────────────────────────────────────────┐
qemu/x86_64/Dockerfile:11: ENV PATH /usr/local/go/bin:$PATH │
────────────────────────────────────────────────────────────┘
│ 11 │                                                                      │ 11 │
│ 12 │WORKDIR /runq                                                         │ 12 │WORKDIR /runq
│ 13 │                                                                      │ 13 │
│    │                                                                      │ 14 │
│    │                                                                      │ 15 │RUN ln -sf /proc/mounts:/etc/mtab

────────────────────────────────────────────────────────────────┐
qemu/x86_64/Dockerfile:70: RUN cp -d --preserve=all --parents \ │
────────────────────────────────────────────────────────────────┘
│ 67 │  /usr/lib/x86_64-linux-gnu/* \                                       │ 70 │  /usr/lib/x86_64-linux-gnu/* \
│ 68 │  $QEMU_ROOT/ 2>&1 | grep -v 'omitting directory';:                   │ 71 │  $QEMU_ROOT/ 2>&1 | grep -v 'omitting directory';:
│ 69 │                                                                      │ 72 │
│    │                                                                      │ 73 │RUN cp -a --parents \
│    │                                                                      │ 74 │    /proc/mounts \
│    │                                                                      │ 75 │    $QEMU_ROOT
│    │                                                                      │ 76 │
│ 70 │ RUN cp -a --parents \                                                │ 77 │ RUN cp -a --parents \
│ 71 │     /etc/mtab \                                                      │ 78 │#     /etc/mtab \
│ 72 │     /usr/bin/qemu-system-x86_64 \                                    │ 79 │     /usr/bin/qemu-system-x86_64 \
│ 73 │     /usr/bin/rsync \                                                 │ 80 │     /usr/bin/rsync \
│ 74 │     /usr/lib64/ld-linux-x86-64.so.2 \                                │ 81 │     /usr/lib64/ld-linux-x86-64.so.2 \
pmorjan commented 5 months ago

please have a look at the new branch ubuntu2204.