Skip to content

Instantly share code, notes, and snippets.

@sebastianwebber
Created June 26, 2020 17:36
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastianwebber/2c1e9c7df97e05479f22a0d13c00aeca to your computer and use it in GitHub Desktop.
Save sebastianwebber/2c1e9c7df97e05479f22a0d13c00aeca to your computer and use it in GitHub Desktop.
How to install buildah on ubuntu 20.04

install-buildah-ubuntu-20.04.md

. /etc/os-release
sudo sh -c "echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list"
wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/xUbuntu_${VERSION_ID}/Release.key -O Release.key
sudo apt-key add - < Release.key
sudo apt-get update -qq
sudo apt-get -qq -y install buildah
``
@Myhael76
Copy link

Myhael76 commented Mar 22, 2022

Sorry, does not work...

I managed to get it working with the following. It seems the prerequisites are not clearly specified.

sudo apt-get -y update
sudo apt-get install -y wget
sudo apt-get -y install ca-certificates
sudo apt-get -y install gnupg2
sudo echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04/ /' | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
sudo wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/xUbuntu_20.04/Release.key -O /tmp/Release.key
sudo apt-key add - < /tmp/Release.key
sudo apt-get -y update -qq

@dogukancagatay
Copy link

Shorter, dynamic, working, copy-paste version:

. /etc/os-release && \
apt-get update && \
apt-get install -y ca-certificates curl gnupg2 && \
echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list && \
curl -fsL "https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/xUbuntu_${VERSION_ID}/Release.key" | apt-key add - && \
apt-get update && \
apt-get install -y buildah

@chad-green
Copy link

Looks like buildah is no longer in this repository. podman is still there, though. Anyone know where we can still find buildah for 20.04?

@dogukancagatay
Copy link

buildah is included in the default package repositories for >= Ubuntu 20.10.

For Ubuntu 20.04, it looks like, we need to build buildah from source right now, since there is no pre-build binary. Building instructions are here.

@chad-green
Copy link

@dogukancagatay were you able to get the build from source to work? I tried building from source as described, but I think there are some broken dependencies. You need golang-1.17 or higher to install the container-networking plugins, but to compile buildah, it calls out golang-1.13. After installing the plugins, I installed golang-1.13 and verified it's being used, but this command:
PATH=/usr/lib/go-1.13/bin:$PATH make runc all SECURITYTAGS="apparmor seccomp"
fails with the following error:

HEAD is now at 425e105d VERSION: release 1.0.0-rc8
ln -sf ../../opencontainers/runc/runc
GO111MODULE=on go build -mod=vendor -ldflags '-X main.GitCommit=4b8e5d4b -X main.buildInfo=1653166826 -X main.cniVersion=v1.1.0 ' -gcflags "" -o bin/buildah -tags "apparmor seccomp     " ./cmd/buildah
build github.com/containers/buildah/cmd/buildah: cannot load io/fs: open /home/work/buildah/src/github.com/containers/buildah/vendor/io/fs: no such file or directory

@dogukancagatay
Copy link

dogukancagatay commented May 24, 2022

@chad-green I wasn't able to build with the instructions from the install.md provided in buildah repository as well (sorry for directing you to wrong instructions), but I managed to build buildah from source on Ubuntu 20.04 using the following commands.

I used golang 1.16 because It was complaining with 1.13.

export DEBIAN_FRONTEND=noninteractive

# Get dependencies
apt-get update
apt-get install -y \
    curl \
    build-essential \
    libbtrfs-dev \
    make \
    bats \
    git \
    libapparmor-dev \
    libdevmapper-dev \
    libglib2.0-dev \
    libgpgme11-dev \
    libseccomp-dev \
    libselinux1-dev

# Install goenv and golang
git clone https://github.com/syndbg/goenv.git ~/.goenv
echo 'export GOENV_ROOT="$HOME/.goenv"' >> ~/.bashrc
echo 'export PATH="$GOENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(goenv init -)"' >> ~/.bashrc
source ~/.bashrc
goenv install 1.16.15
goenv global 1.16.15
source ~/.bashrc

# Clone buildah and build
git clone https://github.com/containers/buildah ${GOPATH}/src/github.com/containers/buildah
cd ${GOPATH}/src/github.com/containers/buildah
go get -d ./
export GO111MODULE=auto
make runc all SECURITYTAGS="apparmor seccomp"

@KDMichaelis
Copy link

KDMichaelis commented Jul 18, 2022

@dogukancagatay Your instructions worked for me but only after a few adjustments. For instance, I was missing runc and uidmap (which wasn't necessary for installation but e.g. for buildah login, cf. this comment in the skopeo repo). I also installed them via apt. Maybe you could add them to the list of dependencies. Also your approach with goenv didn't work for me at first, so I simply installed go following the instructions here. I encountered an error in the make command which I fixed loosely following this article.
Except for the runc dependency I wouldn't suggest changing your instructions though, but maybe if someone encounters the same problems as me in the future these resources will help.

@claravanstaden
Copy link

@Myhael76
Copy link

This works for me with Ubuntu 20.04 in Azure. I am using this to update the Azure DevOps agents because I am using buildah in the pipelines.
However, every now and then I get:

E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process NNNN (apt-get)

On the install command, as it seems the update command leaves something in background and returns control before finishing... That is not very nice for unattended scripts.

@theJaxon
Copy link

theJaxon commented Jul 3, 2023

For anyone still stuck with this, this works. 😄 https://fabianlee.org/2022/08/02/buildah-installing-buildah-and-podman-on-ubuntu-20-04/

Worked for me, thank you.

Also I'm pasting same instructions just in case something happens to the site hosting them

# prereq packages
sudo apt-get update

sudo apt-get install -y wget ca-certificates gnupg2

# add repo and signing key
VERSION_ID=$(lsb_release -r | cut -f2)

echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel-kubic-libcontainers-stable.list

curl -Ls https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/xUbuntu_$VERSION_ID/Release.key | sudo apt-key add -

sudo apt-get update

# install buildah and podman
sudo apt install buildah podman -y

# fix known issue 11745 with [machine] entry
sudo sed -i 's/^\[machine\]$/#\[machine\]/' /usr/share/containers/containers.conf

@Tobeabellwether
Copy link

@theJaxon thanks your answer works for me

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