Skip to content

Instantly share code, notes, and snippets.

@joaodubas
Created July 25, 2014 19:32
Show Gist options
  • Save joaodubas/66f8749b0d1d3cce5e64 to your computer and use it in GitHub Desktop.
Save joaodubas/66f8749b0d1d3cce5e64 to your computer and use it in GitHub Desktop.
docker image to install nsinit
# nsinit installer
#
# VERSION: see `TAG`
FROM ubuntu:14.04
MAINTAINER Joao Paulo Dubas "joao.dubas@gmail.com"
# install deps
RUN apt-get -y -qq --force-yes update \
&& apt-get -y -qq --force-yes install build-essential wget git
# download golang
ENV GOVERSION 1.3
ENV GOFILE go${GOVERSION}.linux-amd64.tar.gz
ENV GOURL http://golang.org/dl/$GOFILE
RUN mkdir -p /opt/src \
&& cd /opt/src \
&& wget ${GOURL} \
&& tar -xzf ${GOFILE}
# install golang
RUN mkdir -p /opt/bin \
&& ln -s /opt/src/go/bin/* /opt/bin/
ENV PATH /opt/bin:$PATH
# configure golang
RUN mkdir -p /opt/go
ENV GOROOT /opt/src/go
ENV GOPATH /opt/go
ENV PATH $GOPATH/bin:$PATH
# install nsinit
RUN go get -d github.com/docker/libcontainer/nsinit/nsinit \
&& go install github.com/docker/libcontainer/nsinit/nsinit \
&& cp ${GOPATH}/bin/nsinit /
# add installer
ADD installer /installer
# configure container
CMD ["/installer"]
#!/bin/sh
# Copied from https://github.com/jpetazzo/nsenter
if mountpoint -q /target; then
echo "Installing nsinit to /target"
cp /nsinit /target
else
echo "/target is not a mountpoint"
echo "You can either:"
echo " - re-run this container with -v /usr/local/bin:/target"
echo " - extract nsinit binary (located at /nsinit)"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment