Tuesday, January 17, 2023

Podman in WSL2

For Debian 11 distro in WSL2, following are the commands to install podman (v3.0.1) and configuring it in order to avoid error during execution of podman commands. As in WSL2 there is no systemd so need to update 'cgroup_manager' and 'event_logger'.

 

$ sudo apt-get install podman

$ sudo vim /etc/containers/registries.conf

unqualified-search-registries = ["docker.io"]

 

$ sudo cp /usr/share/containers/containers.conf ${HOME}/.config/containers/libpod.conf 

[engine]
cgroup_manager = "cgroupfs"
events_logger = "file"
 

$ sudo cp ${HOME}/.config/containers/libpod.conf /etc/containers/containers.conf

 

For running Flask application in container, use tiangolo/uwsgi-nginx:python3.8 as base image hosted on docker.io

 

$ podman build -t test02

$ podman run --rm --name tester -p 8080:80 localhost/test02

 

Since by default, podman is not allowed to run container on privileged ports like 80, in above example running it on 8080 or else need to edit sysctl.conf

 

$ sudo vim /etc/sysctl.conf

net.ipv4.ip_unprivileged_port_start=0

$ sudo sysctl -p    # to apply changes


It can be accessed from web-browser on host as http://localhost:8080

 

For error "/" is not shared mount:

$ findmnt -o PROPAGATION /
PROPAGATION
private
$ uname -r
5.10.16.3-microsoft-standard-WSL2 
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04 LTS
Release:        22.04
Codename:       jammy
 
# add in /etc/rc.local or /etc/rc.conf 
$ sudo mount --make-rshared / 

 

$ sudo usermod --add-subuids 10000-75535 USERNAME
$ sudo usermod --add-subgids 10000-75535 USERNAME 

 

No comments:

Post a Comment