Code Monkey home page Code Monkey logo

qemu-static-conf's Introduction

The latest versions of Docker for Windows and Docker for Mac can build non-native architecture containers. I reached out to Anil Madhavapeddy, an engineer at Docker, asking about why it wasn't the case on Linux, turns out Linux can too, there's just an issue with some distributions of qemu-user-static that's disallowing the functionality. These files enable (likely among other things) the ability to build arm32v7/* Docker images on a Linux host of a different architecture without putting qemu-*-static binaries in the image itself. (Only tested on Debian 9)

How do I know if I need them?

Run the following command:

systemctl status systemd-binfmt

If you see output like the following [note the start condition failed part]:

computermouth@debian:~$ systemctl status systemd-binfmt
● systemd-binfmt.service - Set Up Additional Binary Formats
   Loaded: loaded (/lib/systemd/system/systemd-binfmt.service; static; vendor preset: enabled)
   Active: inactive (dead) since Thu 2017-07-13 00:06:51 PDT; 5s ago
Condition: start condition failed at Thu 2017-07-13 00:06:51 PDT; 5s ago
           ├─ ConditionDirectoryNotEmpty=|/lib/binfmt.d was not met
           ├─ ConditionDirectoryNotEmpty=|/usr/lib/binfmt.d was not met
           ├─ ConditionDirectoryNotEmpty=|/usr/local/lib/binfmt.d was not met
           ├─ ConditionDirectoryNotEmpty=|/etc/binfmt.d was not met
           └─ ConditionDirectoryNotEmpty=|/run/binfmt.d was not met
     Docs: man:systemd-binfmt.service(8)
           man:binfmt.d(5)
           https://www.kernel.org/doc/Documentation/binfmt_misc.txt
  Process: 12402 ExecStart=/lib/systemd/systemd-binfmt (code=exited, status=0/SUCCESS)
 Main PID: 12402 (code=exited, status=0/SUCCESS)
      CPU: 0

...you will need the files here in one of the above directories. Personally, I've been using them in /lib/binfmt.d.

How do I install?

git clone https://github.com/computermouth/qemu-static-conf.git
sudo mkdir -p /lib/binfmt.d
sudo cp qemu-static-conf/*.conf /lib/binfmt.d/
sudo systemctl restart systemd-binfmt.service

How do I test if it's working

NOTE: You will need to sudo docker below if you haven't set up the appropriate permissions.

echo -e "FROM arm32v7/debian:stretch-slim\n\nRUN echo 'it works'" > Dockerfile
docker build .

If the container succeeds to build without error, you're good to go!

Why isn't this built into Debian/Ubuntu (but it is in Fedora)?

I'm not sure, that systemd service is distributed with them out of the box, but Fedora supplies these files with their qemu-user-static package, while Debian and Ubuntu don't. I've submitted a bug report here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=868217

qemu-static-conf's People

Contributors

claycooper avatar computermouth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

qemu-static-conf's Issues

Instructions don't work for Ubuntu 16.04

Thanks for putting these instructions together, I know this really isn't your burden to bear but I thought I would note some problems I'm having using Ubuntu 16.04

#Description of setup

$ uname -a
Linux virtualbox 4.4.0-116-generic #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ systemctl status systemd-binfmt
● systemd-binfmt.service - Set Up Additional Binary Formats
   Loaded: loaded (/lib/systemd/system/systemd-binfmt.service; static; vendor preset: enabled)
   Active: inactive (dead) since Wed 2018-03-28 12:22:33 EDT; 7s ago
Condition: start condition failed at Wed 2018-03-28 12:22:33 EDT; 7s ago
           none of the trigger conditions were met
     Docs: man:systemd-binfmt.service(8)
           man:binfmt.d(5)
           https://www.kernel.org/doc/Documentation/binfmt_misc.txt
  Process: 4926 ExecStart=/lib/systemd/systemd-binfmt (code=exited, status=0/SUCCESS)
 Main PID: 4926 (code=exited, status=0/SUCCESS)

Mar 28 12:05:19 virtualbox systemd[1]: Starting Set Up Additional Binary Formats...
Mar 28 12:05:19 virtualbox systemd[1]: Started Set Up Additional Binary Formats.
Mar 28 12:22:33 virtualbox systemd[1]: Stopped Set Up Additional Binary Formats.
Mar 28 12:22:33 virtualbox systemd[1]: Stopping Set Up Additional Binary Formats...

#Install steps

$ git clone https://github.com/computermouth/qemu-static-conf.git
$ sudo mkdir -p /lib/binfmt.d
$ sudo cp qemu-static-conf/*.conf /lib/binfmt.d/
$ sudo systemctl restart systemd-binfmt.service
Job for systemd-binfmt.service failed because the control process exited with error code. See "systemctl status systemd-binfmt.service" and "journalctl -xe" for details.

#Post-install systemd info

$ systemctl status systemd-binfmt
● systemd-binfmt.service - Set Up Additional Binary Formats
   Loaded: loaded (/lib/systemd/system/systemd-binfmt.service; static; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2018-03-28 12:27:29 EDT; 2s ago
     Docs: man:systemd-binfmt.service(8)
           man:binfmt.d(5)
           https://www.kernel.org/doc/Documentation/binfmt_misc.txt
  Process: 7562 ExecStart=/lib/systemd/systemd-binfmt (code=exited, status=1/FAILURE)
 Main PID: 7562 (code=exited, status=1/FAILURE)

Mar 28 12:27:29 virtualbox systemd[1]: Starting Set Up Additional Binary Formats...
Mar 28 12:27:29 virtualbox systemd-binfmt[7562]: Failed to add binary format: Invalid argument
Mar 28 12:27:29 virtualbox systemd-binfmt[7562]: Failed to add binary format: Invalid argument
Mar 28 12:27:29 virtualbox systemd-binfmt[7562]: Failed to add binary format: Invalid argument
Mar 28 12:27:29 virtualbox systemd[1]: systemd-binfmt.service: Main process exited, code=exited, status=1/FAILURE
Mar 28 12:27:29 virtualbox systemd[1]: Failed to start Set Up Additional Binary Formats.
Mar 28 12:27:29 virtualbox systemd[1]: systemd-binfmt.service: Unit entered failed state.
Mar 28 12:27:29 virtualbox systemd[1]: systemd-binfmt.service: Failed with result 'exit-code'.

Any advice would be appreciated!

Need to restart systemd-binfmt sometimes

Hello,

I follow instructions and my docker image has started, thanks

I don't know if it's the better place to expose my problem.
To give a context, I run automated test on my Ubuntu 18.04 server who use docker (arm) and sometimes, I got standard_init_linux.go:190: exec user process caused "no such file or directory". If I run sudo systemctl restart systemd-binfmt and try to rebuild my docker image, it works

Can you help me to avoid service restart ?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.