curtismuntz / bazel_examples

Bazel Examples
MIT License
2 stars 0 forks source link

Running docker image on OSX #1

Open pickledgator opened 6 years ago

pickledgator commented 6 years ago

Followed blog tutorial through docker build stage, but when I tried to run the docker image, I got this error:

➜  bazel_examples git:(master) docker run --rm -it bazel/deploy:hello_cpp_image
standard_init_linux.go:195: exec user process caused "exec format error"

A quick google says that I'm trying to run something built for a different architecture. But since the docker internally can be linux, I'm not sure what the issue is? Thoughts?

curtismuntz commented 6 years ago

It depends on how you built this target. If you build the target with standard build options ie: bazel run //deploy:hello_cpp_image, it should run just fine natively.

If you specified it to build with the rpi crosstool, all the binaries within the image will be built for an armv7 platform. Since your computer is likely not an armv7 cpu, it will report the exec format error.

pickledgator commented 6 years ago

Cool that works. So you're just saying I can build the docker for armv7 but cant run it on osx. Ie, I can't use the docker as an emulator?

curtismuntz commented 6 years ago

You can, but I haven't set it up that way in this project. resin provides an excellent example of emulation here: https://resin.io/blog/building-arm-containers-on-any-x86-machine-even-dockerhub/. In the event you wanted to run an emulation session, you would just never call the cross-build-end.sh script.

My intent for this project was to develop locally using the standard bazel methods, and deploy to arm once you've verified that the software works as intended.