I am creating a Ubuntu 12.04 docker image that has gcc 4.8.5. I am getting gcc 4.8.5 source and building it myself. This container will be running on a Ubuntu 18.04 host.
Referencing the code at the bottom, if I don't put this in the dockerfile and run the same commands after starting the container, the build works fine, however if I use RUN instead in the dockerfile, I get the following build error
In file included from /usr/include/stdio.h:28:0,
from ../../../gcc-4.8.5/libgcc/../gcc/tsystem.h:87,
from ../../../gcc-4.8.5/libgcc/libgcc2.c:27:
/usr/include/features.h:324:26: fatal error: bits/predefs.h: No such
file or directory
#include <bits/predefs.h>
^
The problem seems to stem from the ./gcc-4.8.5/configure call. When run inside the container i get:
checking build system type... i686-pc-linux-gnu
When put in the dockerfile i get:
checking build system type... x86_64-unknown-linux-gnu
Can someone fill in my understanding of the RUN in dockerfiles because i feel like i am missing something about how its working. I was under the impression that those commands would run in the previous layer? But it seems like they are running on my host.
## Get gcc 4.8.5 and build it
RUN wget ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.8.5/gcc-4.8.5.tar.gz \
&& tar xzf gcc-4.8.5.tar.gz && \
cd gcc-4.8.5 && \
./contrib/download_prerequisites && \
cd .. && mkdir gccbuild && cd gccbuild && \
../gcc-4.8.5/configure \
--prefix="/opt/gcc" \
--enable-shared --with-system-zlib --enable-threads=posix \
--enable-__cxa_atexit --enable-checking --enable-gnu-indirect-function \
--enable-languages="c,c++" --disable-bootstrap \
&& make all && make install
EDIT:
docker build -t 12.04_builder - < dockerfile
docker run -i -t 12.04_builder
Complete dockerfile:
FROM jnickborys/i386-ubuntu:12.04
RUN apt-get update && \
apt-get install -y \
wget \
build-essential \
libssl-dev \
git \
asciidoc \
libpulse-dev \
libasound2-dev \
libpcsclite-dev
## Get latest cmake that has a 32-bit version
RUN wget https://github.com/Kitware/CMake/releases/download/v3.6.3/cmake-3.6.3-Linux-i386.sh && \
chmod +x cmake-3.6.3-Linux-i386.sh && \
./cmake-3.6.3-Linux-i386.sh --skip-license --prefix=/usr
## Get gcc 4.8.5 and build it
RUN wget ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.8.5/gcc-4.8.5.tar.gz \
&& tar xzf gcc-4.8.5.tar.gz && \
cd gcc-4.8.5 && \
./contrib/download_prerequisites && \
cd .. && mkdir gccbuild && cd gccbuild && \
../gcc-4.8.5/configure \
--prefix="/opt/gcc" \
--enable-shared --with-system-zlib --enable-threads=posix \
--enable-__cxa_atexit --enable-checking --enable-gnu-indirect-function \
--enable-languages="c,c++" --disable-bootstrap
&& make all && make install