Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to install nsenter on Ubuntu 14.04
# Ubuntu 14.04 don't have nsenter - the straight forward way required me to install build tools and etc.
# I preferred to keep the system clean and install nsenter in a container and then copy the command to the host
# Note - its also possible to run nsenter from a container (didn't tried) https://github.com/jpetazzo/nsenter
# start a container
docker run --name nsenter -it ubuntu:14.04 bash
## in the docker
apt-get update
apt-get install git build-essential libncurses5-dev libslang2-dev gettext zlib1g-dev libselinux1-dev debhelper lsb-release pkg-config po-debconf autoconf automake autopoint libtool
git clone git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git util-linux
cd util-linux/
./autogen.sh
./configure --without-python --disable-all-programs --enable-nsenter
make
## from different shell - on the host
docker cp nsenter:/util-linux/nsenter /usr/local/bin/
docker cp nsenter:/util-linux/bash-completion/nsenter /etc/bash_completion.d/nsenter
@herophuong

This comment has been minimized.

herophuong commented Aug 27, 2014

Very nice. Thank you very much!

@joelacrisp

This comment has been minimized.

joelacrisp commented Jul 22, 2015

Fantastic, thanks!

@DiganmeGiovanni

This comment has been minimized.

DiganmeGiovanni commented Sep 10, 2015

Nice solution. Thanks!

@cgrandsjo

This comment has been minimized.

cgrandsjo commented Jan 27, 2016

Very nice!

I got this error

configure: error: conditional "HAVE_SCHED_SETATTR" was never defined.
Usually this means the macro was only invoked conditionally.

when using

./configure --without-python --disable-all-programs --enable-nsenter

if I instead use

./configure --without-python --enable-nsenter
make nsenter

it works!

@Mufasa

This comment has been minimized.

Mufasa commented Mar 5, 2016

I used the method described and it certainly works however, I was watching a pluralsight course (Docker Deep Dive by Nigel Poulton) where he showed a simpler way of installing this.

Simply run this on your docker host:
docker run -v /usr/local/bin:/target jpetazzo/nsenter

@Johnzinvalid

This comment has been minimized.

Johnzinvalid commented Aug 17, 2016

nice one

@banji-ajayi

This comment has been minimized.

banji-ajayi commented Sep 13, 2017

love this

@sagar8192

This comment has been minimized.

sagar8192 commented Jan 16, 2018

I had to install bison as well.

@mendoncangelo

This comment has been minimized.

mendoncangelo commented Oct 3, 2018

I need to add a apt-get install -y bison.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment