ryankurte / docker-rpi-emu

QEMU and helper scripts in a docker container for emulating a raspberry pi environment
MIT License
109 stars 34 forks source link

ps, top commands do not work inside the container #9

Closed rajr0 closed 5 years ago

rajr0 commented 7 years ago

docker run -it --rm --privileged=true -v /home/user1/docker/my-raspberry/:/usr/rpi/images -w /usr/rpi docker-rpi-emu /bin/bash -c './run.sh images/4graspi.img /bin/bash' Attempting to mount images/4graspi.img to /media/rpi Attached base loopback at: /dev/loop0 Located partitions: p1 (/boot) at 8192 and p2 (/) at 137216 Closed loopback /dev/loop0 Mounted to /media/rpi and /media/rpi/boot Bootstrapping Qemu root@5f412aa3147b:/# ps Error: /proc must be mounted To mount /proc at boot you need an /etc/fstab line like: proc /proc proc defaults In the meantime, run "mount proc /proc -t proc" root@5f412aa3147b:/# uname -a Linux 5f412aa3147b 4.4.0-45-generic #66~14.04.1-Ubuntu SMP Wed Oct 19 15:05:38 UTC 2016 armv7l GNU/Linux root@5f412aa3147b:/#

rajr0 commented 7 years ago

I think the problem I mentioned above is solved by the following changes. I followed the instructions in https://wiki.debian.org/RaspberryPi/qemu-user-static

diff --git a/scripts/run.sh b/scripts/run.sh index 483dac2..1d69dd2 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -32,6 +32,10 @@ mkdir -p $MOUNT_DIR ./qemu-setup.sh $MOUNT_DIR

Launch QEMU

+mount --bind /proc $MOUNT_DIR/proc/ +mount --bind /dev $MOUNT_DIR/dev/ +mount --bind /sys $MOUNT_DIR/sys/ +mount --bind /dev/pts $MOUNT_DIR/dev/pts chroot $MOUNT_DIR $COMMAND

Remove QEMU

With the above changes, I re-ran the command as follows, to avoid re-building container. And I'm able to execute - ps, top, etc. docker run -it --rm --privileged=true -v /home/user1/docker/my-raspberry/docker-rpi-emu/scripts/:/usr/rpi/ -v /home/user1/docker/my-raspberry/:/usr/rpi/images -w /usr/rpi docker-rpi-emu /bin/bash -c './run.sh images/4graspi.img /bin/bash' Attempting to mount images/4graspi.img to /media/rpi Attached base loopback at: /dev/loop0 Located partitions: p1 (/boot) at 8192 and p2 (/) at 137216 Closed loopback /dev/loop0 Mounted to /media/rpi and /media/rpi/boot Bootstrapping Qemu root@bcf2ef1038cc:/# ps PID TTY TIME CMD 30 ? 00:00:00 ps root@bcf2ef1038cc:/# uname -a Linux bcf2ef1038cc 4.4.0-45-generic #66~14.04.1-Ubuntu SMP Wed Oct 19 15:05:38 UTC 2016 armv7l GNU/Linux root@bcf2ef1038cc:/#

ryankurte commented 7 years ago

Yep, I didn't have any of the other points mounted since we haven't had the need. Would be happy to accept a pull request if you fancy opening one!

ryankurte commented 5 years ago

thanks for the fix!