rust - How can I use dynamic linking in a Docker image based on busybox? -


on ubuntu machine, have http server rust binary dynamically linked against glibc (the default target), , want put my-rust-app docker busybox base image. copying each of libraries busybox @ /usr/lib didn't seem work , ld_library_path didn't seem work @ runtime either. need pass special options cargo @ compile time?

here's current setup:

$ rustc --version rustc 1.7.0 (a5d1e7a59 2016-02-29) $ cargo --version cargo 0.8.0-nightly (28a0cbb 2016-01-17) 

update 1:

the build process , linked libraries:

/$ cargo build --release /$ cd target/release /target/release$ mkdir /target/release$ ldd my-rust-app     linux-vdso.so.1 =>  (0x00007fffc0b97000)     libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1f270d7000)     libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f1f26eb9000)     libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1f26ca3000)     libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1f268de000)     /lib64/ld-linux-x86-64.so.2 (0x00007f1f27686000)     libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1f265d8000) 

i copy each of (except linux-vdso.so injected process @ runtime):

/target/release$ mkdir /target/release$ cp /lib/x86_64-linux-gnu/libdl.so.2 so/ /target/release$ cp /lib/x86_64-linux-gnu/libpthread.so.0 so/ /target/release$ cp /lib/x86_64-linux-gnu/libgcc_s.so.1 so/ /target/release$ cp /lib/x86_64-linux-gnu/libc.so.6 so/ /target/release$ cp /lib/x86_64-linux-gnu/libm.so.6 so/ 

my dockerfile uses busybox image @ glibc tag:

/target/release$ cat dockerfile  busybox:glibc expose 3000 workdir /usr/bin copy my-rust-app . copy so/ /usr/lib env ld_library_path="/usr/lib" entrypoint ["/usr/bin/my-rust-app"] 

once image my-rust-app built, try run app in container:

/target/release$ docker run -d -p 3000:3000 --name my-rust-app my-rust-app 9aaf3c9b0e6d52511723382b5248da3c59397acca5f60637644ba311ec394d5e 

looking @ docker logs, see output server:

/target/release$ docker logs my-rust-app listening on port 3000 

however, unable curl endpoint:

/target/release$ curl http://127.0.0.1:3000/ curl: (56) recv failure: connection reset peer 

if try run same my-rust-app directly in ubuntu host, can start server , curl successfully:

/target/release$ ./my-rust-app & [1] 6131 listening on port 3000  /target/release$ curl http://127.0.0.1:3000/health got request /health {"status":"ok"} 

what's wrong container or rust binary?


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -