I am trying to cargo build Azure IoT edge security daemon code (edgelet) in a docker. This goes smoothly on my Ubuntu machine. However, an issue occurs when I try to compile in Docker.
Here is the issue:
Compiling k8s-openapi v0.4.0
error: inclusive range syntax is experimental (see issue #28237)
--> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/k8s-openapi-0.4.0/build.rs:10:19
|
10 | for v2 in MIN..=MAX {
| ^^^^^^^^^
error: inclusive range syntax is experimental (see issue #28237)
--> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/k8s-openapi-0.4.0/build.rs:32:14
|
32 | for v in MIN..=MAX {
| ^^^^^^^^^
error: inclusive range syntax is experimental (see issue #28237)
--> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/k8s-
openapi-0.4.0/build.rs:117:14
|
117 | for v in MIN..=MAX {
| ^^^^^^^^^
error: aborting due to 3 previous errors
error: Could not compile `k8s-openapi`.
Here is a portion of my Docker file:
RUN apt-get update && \
apt-get install -y --no-install-recommends --allow-unauthenticated\
curl\
cargo
WORKDIR /usr/app
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
COPY edgelet .
RUN cargo build
Please check rustc's version which used in your docker image and version of the compiler on your Ubuntu machine.
The only possible reason for that behavior is you have old version of rustc in your docker image.
Related
I have a Dockerfile where I want to run the following command to get Rust and Cargo:
RUN curl https://sh.rustup.rs -sSf | sh
However, when executing it by hand in the terminal (not in the Dockerfile, but just running curl https://sh.rustup.rs -sSf | sh), it asks me to include the type of installation by hand:
Current installation options:
default host triple: x86_64-unknown-linux-gnu
default toolchain: stable (default)
profile: default
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
> 1 (this is what i enter)
Thus, when executing the above in the Dockerfile, it is not possible to select the option and it gives me the following error.
Step 3/6 : RUN curl https://sh.rustup.rs -sSf | sh
---> Running in d03d6ff33b9f
info: downloading installer
rustup: Unable to run interactively. Run with -y to accept defaults, --help for additional options
The command '/bin/sh -c curl https://sh.rustup.rs -sSf | sh' returned a non-zero code: 1
Do you know how I should proceed in the Dockerfile to introduce 1) Proceed with installation (default) and avoid the error?
Thank you in advance
use: curl https://sh.rustup.rs -sSf | sh -s -- -y
as mentioned here: https://github.com/rust-lang-deprecated/rustup.sh/issues/83
I am building a docker container for compiling a mix of rust, carbon and c.
Everything seems to work until running main.carbon and call the function of my rust library. Although the import seems valid. I think that is an issue by Rust code.
This is my Dockerfile:
#
# -------- ---------- -----
# | rust | | carbon | | C |
# -------- ---------- -----
# | | |
# | | |
FROM rust as rust
WORKDIR /usr/src/myapp
COPY ./src/lib/ .
RUN cargo build --verbose --release --all-targets --manifest-path /usr/src/myapp/Cargo.toml
# | |
# install carbon | |
# ------| |
# | | |
FROM linuxbrew/brew as brew
RUN brew update
RUN brew install python#3.9
RUN brew install bazelisk
RUN brew install llvm
# | |
# | |
# | |
# | |
FROM brew as carbon
RUN git clone https://github.com/carbon-language/carbon-lang carbon
WORKDIR /home/linuxbrew/carbon
COPY --from=rust /usr/src/myapp/target/release/librust_file_listener.so /home/linuxbrew/carbon/explorer/
SHELL ["/bin/bash", "-c"]
RUN mv -v /home/linuxbrew/carbon/explorer/BUILD /home/linuxbrew/carbon/explorer/ BUILD-old
RUN touch ./explorer/BUILD
RUN echo $(pwd)
RUN sed -n '1,17p' ./explorer/BUILD-old >> ./explorer/BUILD
RUN echo ' srcs = ["main.cpp", "librust_file_listener.so"],' >> ./explorer/BUILD
RUN sed -n '19,$p' ./explorer/BUILD-old >> ./explorer/BUILD
RUN cp ./explorer/librust_file_listener.so .
RUN bazel build --verbose_failures //explorer
COPY ./src/main.carbon .
COPY ./src/file-listener.h .
RUN bazel run //explorer -- ./main.carbon
This is my error message:
/root/.cache/bazel/_bazel_root/c2431547aff5b972703b3babc3d841cc/execroot/carbon/bazel-out/k8-fastbuild/bin/explorer/explorer:
error while loading shared libraries: libstd-69edc9ac8de4d39c.so:
cannot open shared object file: No such file or directory
Searching for this error message: the only result was this question by laurent. May be corresponding!?
FYI I am on x86_64, not on ARM.
I run the same Docker build on two machines:
Ubuntu 16.04
Debian 9.7
Everything works fine in Ubuntu but this is the problem I have in Debian during the Docker build:
The command '/bin/sh -c php7 /installer.php --install-dir=/usr/bin --filename=composer' returned a non-zero code: 139
This is my Dockerfile:
FROM nginx:1.14-alpine
...
...
RUN curl https://getcomposer.org/installer -o /installer.php
RUN php7 /installer.php --install-dir=/usr/bin --filename=composer
...
...
In Linux, the error code 139 indicates a segmentation fault.
I have a memory of 15437156 kB on Debian (Docker version 18.06.2-ce) and 16147116 kB on Ubuntu (Docker version 18.05.0-ce).
Note: The problem happens during the build docker build ...
Do you know how to fix this on Debian?
I was facing the issuse
The command '/bin/sh -c rpm -ivh jdk-8u172-linux-x64.rpm' returned a non-zero code: 139
then i switched to using the legacy hyper-V instead of the WSL 2 that is provided by the docker engine, then everything worked fine
I was upgrading some versions and started hitting a similar issue to you, googled and found your post here. I was getting:
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && php composer-setup.php && php -r "unlink('composer-setup.php');" && mv composer.phar /usr/local/bin/composer
---> Running in e73735530b5d
All settings correct for using Composer
Segmentation fault
After some testing I found that using FROM alpine:3.9 caused it to Seg fault every time, but downgrading my Alpine version to FROM alpine:3.8 stopped it occurring.
Not sure why though, but looks like there's something broken in the latest version of Alpine as I also didn't get this issue in Debian, Debian Slim, or Ubuntu 18:04.
Say I want to rebuild my docker image when a new compiler version is available in some repository.
I can gather the version inside the container:
FROM centos:7
RUN yum info gcc | grep Version | sort | tail -1 | cut -d: -f2 | tr -d ' '
If I build this container and tag it as base, I can use that information and setup a second container:
FROM base
RUN yum install gcc-4.8.5
Docker will be able to cache the second container and not rebuild it, when the compiler version has not changed. But creating that requires some shell scripting and that might be brittle in, e.g., a continuous integration scenario.
What I would like to do is to introduce a unified source for these two containers. Is there a way to write something like this:
FROM centos:7
$GCC_VERSION=RUN yum info gcc | grep Version | sort | tail -1 | cut -d: -f2 | tr -d ' '
RUN yum install gcc-$GCC_VERSION
and have the variables expanded (and the commands still cached) during docker build ?
You can use the ARG instruction. Build args affect the cache in the way you want to: Impact on build caching
With a Dockerfile like this:
FROM centos:7
ARG GCC_VERSION
RUN yum install -y gcc-$GCC_VERSION
The image gets only rebuilt if the GCC_VERSION changes.
docker build --build-arg GCC_VERSION=$(docker run centos:7 yum info gcc | grep Version | sort | tail -1 | cut -d: -f2 | tr -d ' ') .
Qpid-cpp has been compiled in a Ubuntu docker image and the current size is 1.86GB:
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu-qpid-cpp latest 7e60a5eabee1 44 hours ago 1.86 GB
Aim
To compile qpid-cpp within docker alpine to reduce the disk size of the image
Problem
Some packages that are available in Ubuntu are omitted or different in Alpine, e.g.:
ubuntu
RUN apt-get update -y && \
apt-get install -y wget && \
apt-get install -y build-essential python ruby && \
apt-get install -y cmake libblkid-dev e2fslibs-dev libboost-all-dev libaudit-dev
Attempt
In order to find the substitution packages the Dockerfile was built and when an error occurred the required package that is available in Alpine was added.
alpine
RUN apk update && \
apk add wget python ruby cmake build-base boost-dev util-linux-dev
Although most errors were solved, the following issue occurs while compile qpid-cpp within alpine:
[ 17%] Building CXX object
src/CMakeFiles/qpidcommon.dir/qpid/sys/posix/Condition.cpp.o
In file included from
/qpid-cpp/bld/qpid-cpp-1.36.0/src/qpid/sys/posix/Condition.h:31:0,
from /qpid-cpp/bld/qpid-cpp-1.36.0/src/qpid/sys/posix/Condition.cpp:22:
/usr/include/sys/errno.h:1:2: error: #warning redirecting incorrect
#include <sys/errno.h> to <errno.h> [-Werror=cpp]
#warning redirecting incorrect #include <sys/errno.h> to <errno.h>
^~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [src/CMakeFiles/qpidcommon.dir/build.make:2727:
src/CMakeFiles/qpidcommon.dir/qpid/sys/posix/Condition.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1494: src/CMakeFiles/qpidcommon.dir/all]
Error 2 make: *** [Makefile:161: all] Error 2
The command '/bin/sh -c cd qpid-cpp/bld/qpid-cpp-1.36.0 && make all && make
install' returned a non-zero code: 2
Question
How to solve the compilation issue Building CXX object src/CMakeFiles/qpidcommon.dir/qpid/sys/posix/Condition.cpp.o while compiling qpid-cpp within Docker Alpine?
I tried this with Ubuntu and Alpine docker images, and I get the same problem on Alpine. It appears that qpid won't build on Alpine Linux.
Be aware that the Ubuntu:16.04 image is 130 MB, 750 MB with dependencies installed. Compared to Alpine's 5 MB, and 476 MB with dependencies.
So those 1.86 GB are mostly made up of build dependencies and qpid itself. You won't be able to escape that with any other image. Maybe you could purge some of the build dependencies after building to decrease the final size.