At some point, a newer version of a package is required …
My example here is building lxc for debian wheezy. Wheezy itself has 0.8.x in its repositories, but 1.0.6 from the jessie repos is desired.
# We use the debian wheezy base image
FROM debian:wheezy
# Install dpkg-dev from wheezy
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y dpkg-dev; \
# Patch sources list to contain wheezy-backports and jessie
echo "deb http://ftp.de.debian.org/debian/ jessie main non-free contrib" >> /etc/apt/sources.list.d/jessie.list; \
echo "deb-src http://ftp.de.debian.org/debian/ jessie main non-free contrib" >> /etc/apt/sources.list.d/jessie.list: \
echo "deb http://ftp.de.debian.org/debian/ wheezy-backports main" >> /etc/apt/sources.list: \
apt-get update; \
WORKDIR /root
# Now we get the source
RUN apt-get source lxc
# Remove jessie sources.list and install build dependencies
RUN rm /etc/apt/sources.list.d/jessie.list && apt-get update
RUN apt-get install -y build-essential fakeroot dpkg-dev dh-autoreconf doxygen docbook2x graphviz libapparmor-dev liblua5.2-dev libseccomp-dev libselinux-dev pkg-config python3-dev dh-systemd libcap-dev
# Switch to lxc directory and build the package
RUN cd lxc-1.0.6; dpkg-buildpackage -b
# Create output volume, running the container just copies the
VOLUME /output
CMD cp *.deb /output
docker build -t lxc-build .
docker run --rm /tmp:/output lxc-build
FROM debian:wheezy
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y dpkg-dev; \
echo "deb http://ftp.de.debian.org/debian/ jessie main non-free contrib" >> /etc/apt/sources.list.d/jessie.list; \
echo "deb-src http://ftp.de.debian.org/debian/ jessie main non-free contrib" >> /etc/apt/sources.list.d/jessie.list: \
echo "deb http://ftp.de.debian.org/debian/ wheezy-backports main" >> /etc/apt/sources.list: \
apt-get update; \
WORKDIR /root
RUN apt-get source lxc
RUN rm /etc/apt/sources.list.d/jessie.list && apt-get update
RUN apt-get install -y build-essential fakeroot dpkg-dev dh-autoreconf doxygen docbook2x graphviz libapparmor-dev liblua5.2-dev libseccomp-dev libselinux-dev pkg-config python3-dev dh-systemd libcap-dev
RUN cd lxc-1.0.6; dpkg-buildpackage -b
VOLUME /output
CMD cp *.deb /output