ufoscout / docker-compose-wait

A simple script to wait for other docker images to be started while using docker-compose (or Kubernetes or docker stack or whatever)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

exec format error

360disrupt opened this issue · comments

Hi, I'm running the script on a raspberry pi 4& raspbian buster. I get an error: exec format error for the script.

FROM arm32v7/node
ENV NODE_VERSION 11.15.0
WORKDIR ./

# install dependencies
RUN apt-get update;\
    apt-get install qemu qemu-user-static binfmt-support -y;\
    apt-get install i2c-tools -y;

# nodejs packages
COPY package*.json ./
RUN npm install --only=production

# copy app
COPY  src/ ./

# add logs folder
RUN mkdir -p /logs/

# wait for MongoDB launch
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.5.1/wait /wait
RUN chmod +x /wait

EXPOSE 8080

STOPSIGNAL SIGTERM

CMD /wait && npm run start

I found that adding a shebang on top of the script helps, e.g.
http://kimh.github.io/blog/en/docker/gotchas-in-writing-dockerfile-en/

But the wait is of type ELF 64-bit LSB executable, x86-64, version 1 (SYSV) so I guess that won't help at least:

I never worked with rust, so I'm not sure if adding one on top of the entry file works. I could add one (probably here: https://github.com/ufoscout/docker-compose-wait/blob/master/src/lib.rs) and make a PR?

Any help appreciated, thx!

Hi @360disrupt
the prebuilt executable is for an x64 architecture which is the docker default one. So, you cannot use it on a raspberry pi.
You should instead clone this repo and compile it from scratch for your target architecture. This could be as easy as executing these two commands (you need a rust compiler):

> rustup target add armv7-unknown-linux-gnueabihf
> cargo build --target=armv7-unknown-linux-gnueabihf

I'll come back in 3 weeks and test it! Thx

Hi @ufoscout thx for the help. I installed rust. Unfortunately, the build does not work:

cargo build --target=armv7-unknown-linux-gnueabihf
Updating crates.io index
Downloaded port_check v0.1.0
Compiling port_check v0.1.0
Compiling wait v2.5.1 (/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait)
warning: trait objects without an explicit `dyn` are deprecated
--> src/lib.rs:12:25
|
12 | pub fn wait(sleep: &mut crate::sleeper::Sleeper, config: &Config, on_timeout: &mut FnMut()) {
|                         ^^^^^^^^^^^^^^^^^^^^^^^ help: use `dyn`: `dyn crate::sleeper::Sleeper`
    |
        = note: #[warn(bare_trait_objects)] on by default

    warning: trait objects without an explicit `dyn` are deprecated
    --> src/lib.rs:12:84
    |
    12 | pub fn wait(sleep: &mut crate::sleeper::Sleeper, config: &Config, on_timeout: &mut FnMut()) {
    |                                                                                    ^^^^^^^ help: use `dyn`: `dyn FnMut()`

        error: linking with `cc` failed: exit code: 1
        |
            = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-L" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/wait-c5eba4b0ae6b0373.12wixf212lgfgjzz.rcgu.o" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/wait-c5eba4b0ae6b0373.23idujfzyamvxmbb.rcgu.o" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/wait-c5eba4b0ae6b0373.2pk2pqhjvptrpdm0.rcgu.o" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/wait-c5eba4b0ae6b0373.2s1aybtp269uiosd.rcgu.o" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/wait-c5eba4b0ae6b0373.4sesfqqrpxy28sjr.rcgu.o" "-o" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/wait-c5eba4b0ae6b0373" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/wait-c5eba4b0ae6b0373.cjxvp0cpqsf3lnk.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps" "-L" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/debug/deps" "-L" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib" "-Wl,-Bstatic" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/libwait-2e3091b86131e10e.rlib" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/libport_check-6c54df4287fac49d.rlib" "-Wl,--start-group" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libstd-83a4f058944e6814.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libpanic_unwind-e11c7b3b3225afe2.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libbacktrace-13217ede3d276f16.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libbacktrace_sys-621a9ee22da6caa1.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/librustc_demangle-546c844e8071bbeb.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libhashbrown-be9569e4d599746f.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/librustc_std_workspace_alloc-47d8845cef2a3bc5.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libunwind-017511bce73a530c.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libcfg_if-be7979c57a08057b.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/liblibc-d6459c4f0817c67c.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/liballoc-580035dd98451925.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/librustc_std_workspace_core-aee5c24fff305dea.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libcore-8a55a4098920125a.rlib" "-Wl,--end-group" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libcompiler_builtins-9fc4b5be2ba5cc19.rlib" "-Wl,-Bdynamic" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil"
            = note: clang: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]
        ld: unknown option: --as-needed
        clang: error: linker command failed with exit code 1 (use -v to see invocation)


        error: aborting due to previous error

        error: Could not compile `wait`.

hi @360disrupt

Could you provide version numbers of your rust compiler (rustc) and cargo:

$ rustc --version

And

$ cargo --version

Not sure if it is needed to locate the problem, but it might help.

Hi @360disrupt

Could you try adding the following line to the top of the file src/lib.rs

#![ allow( bare_trait_objects ) ]

Tip lifted from this issue.

I can make the warnings go away, but I cannot compile anyway, since I seem to be missing the necessary C header files required for the compilation.

@360disrupt
If you build from a linux x64 machine and you have docker installed locally, you can use this simple procedure (based on cross ) that will take care of all needed low level dependencies for you:

cargo install cross
cross build --target=armv7-unknown-linux-musleabihf --release

I tried it right now and it worked like a charm.

I'll update the docs with this information asap.

hi @360disrupt

Could you provide version numbers of your rust compiler (rustc) and cargo:

$ rustc --version

And

$ cargo --version

Not sure if it is needed to locate the problem, but it might help.

rustc --version
rustc 1.37.0 (eae3437df 2019-08-13)
 cargo --version
cargo 1.37.0 (9edd08916 2019-08-02)
#![ allow( bare_trait_objects ) ]

The err changed a bit:

cargo build --target=armv7-unknown-linux-gnueabihf
   Compiling wait v2.5.1 (/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-L" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/wait-c5eba4b0ae6b0373.12wixf212lgfgjzz.rcgu.o" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/wait-c5eba4b0ae6b0373.23idujfzyamvxmbb.rcgu.o" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/wait-c5eba4b0ae6b0373.2pk2pqhjvptrpdm0.rcgu.o" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/wait-c5eba4b0ae6b0373.2s1aybtp269uiosd.rcgu.o" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/wait-c5eba4b0ae6b0373.4sesfqqrpxy28sjr.rcgu.o" "-o" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/wait-c5eba4b0ae6b0373" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/wait-c5eba4b0ae6b0373.cjxvp0cpqsf3lnk.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps" "-L" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/debug/deps" "-L" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib" "-Wl,-Bstatic" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/libwait-2e3091b86131e10e.rlib" "/Users/user/Projekte/1-NODEJS/grassberry-project/docker-compose-wait/target/armv7-unknown-linux-gnueabihf/debug/deps/libport_check-6c54df4287fac49d.rlib" "-Wl,--start-group" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libstd-83a4f058944e6814.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libpanic_unwind-e11c7b3b3225afe2.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libbacktrace-13217ede3d276f16.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libbacktrace_sys-621a9ee22da6caa1.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/librustc_demangle-546c844e8071bbeb.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libhashbrown-be9569e4d599746f.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/librustc_std_workspace_alloc-47d8845cef2a3bc5.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libunwind-017511bce73a530c.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libcfg_if-be7979c57a08057b.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/liblibc-d6459c4f0817c67c.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/liballoc-580035dd98451925.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/librustc_std_workspace_core-aee5c24fff305dea.rlib" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libcore-8a55a4098920125a.rlib" "-Wl,--end-group" "/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/armv7-unknown-linux-gnueabihf/lib/libcompiler_builtins-9fc4b5be2ba5cc19.rlib" "-Wl,-Bdynamic" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil"
  = note: clang: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]
          ld: unknown option: --as-needed
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

@ufoscout I'm working from MAC OS but I have a Ubuntu VM on parallels. So far I installed

  • git, docker.io
  • cloned the repo again on my VM
  • installed cross with cargo
  • added /root/.cargo/bin to PATH
  • uninstalled rust
  • instaled rustup

I compiled it and the script now works. I can provide wait/ if anybody is interested. Many thx for the guidance.

@ufoscout cross looks really interesting...