Install Podman, Buildah, and Skopeo on Ubuntu 18.04

Install podman and the gang

Execute the following commands to install podman, buildah, and skopeo from Kubic package repository.

. /etc/os-release
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key | sudo apt-key add -
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install podman buildah skopeo

Install slirp4netns

In order to forward ports from container run by podman, you need to install slirp4netns by downloading the executable binary into a directory.

LATEST_VERSION=$(curl -s https://api.github.com/repos/rootless-containers/slirp4netns/releases/latest | jq -r '.tag_name')
curl -fL -o slirp4netns https://github.com/rootless-containers/slirp4netns/releases/download/${LATEST_VERSION}/slirp4netns-$(uname -m)
chmod +x slirp4netns

Add the directory into PATH variable by appending this line to shell init script (e.g. ~/.bashrc or ~/.zshrc) and restart the shell or source it.

export PATH=/path/to/binaries:$PATH

Test podman

Run a httpd container and forward port 8080 -> 18080

podman run -dt -p 18080:8080/tcp registry.fedoraproject.org/f29/httpd

If you see the error ERRO[0001] unable to write pod event: "write unixgram @00018->/run/systemd/journal/socket: sendmsg: no such file or directory", you seem to run podman in WSL2. Then you need to use the flag --events-backend=file to suppress this error:

podman run -dt -p 18080:8080/tcp --events-backend=file registry.fedoraproject.org/f29/httpd

Check the container status

podman ps

Podman will search in default registries if you don't specify full image name. The default registries are defined in /etc/containers/registries.conf. You can use command podman info to see the list of registries.

You should see the container's name and its status should be up like this:

CONTAINER ID  IMAGE                                 COMMAND               CREATED         STATUS            PORTS                    NAMES
6ffe71fff383  registry.fedoraproject.org/f29/httpd  /usr/bin/run-http...  44 seconds ago  Up 5 seconds ago  0.0.0.0:18080->8080/tcp  priceless_saha

Try to access the web page at http://localhost:18080 and you should see a HTML response.

curl http://localhost:18080

Dont' forget to stop and remove the container:

podman container stop priceless_saha
podman container rm priceless_saha

Test buildah

Buildah works the same as docker build, you just need to use podman build instead and everything works the same.

Clone the repository

git clone https://github.com/pacroy/flask-app.git

Build the image

buildah bud -t flask-app .

List all the image on local

buildah images
#OR
podman images

Run the image in a container

podman run -d -p 5000:5000 --events-backend=file flask-app

Check container status

podman ps

Try accessing applciation at http://localhost:5000/ 

Test skopeo

Use the following command to inspect an image properties on a remote repository:

skopeo inspect docker://registry.fedoraproject.org/fedora:latest

Use the following command to inspect an image configuration on a remote registry:

skopeo inspect --config docker://registry.fedoraproject.org/fedora:latest | jq

If you don't have jq installed, you can download it from https://stedolan.github.io/jq/.

You can also inspect your local images pulled by podman by using containers-storage transport.

skopeo inspect containers-storage:localhost/flask-app:latest

Copy an image from local registry to docker.io:

skopeo copy --dest-creds=$user:$password containers-storage:localhost/flask-app:latest docker://docker.io/pacroy/flask-app:latest

References


Revision #23
Created Sun, Dec 20, 2020 2:20 PM by Chairat (Par)
Updated Fri, Feb 5, 2021 1:54 PM by Chairat (Par)