From nobody Sat May 14 15:11:12 2022 X-Original-To: freebsd-jail@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id CCCEA1ACD165 for ; Sat, 14 May 2022 15:11:31 +0000 (UTC) (envelope-from cneirabustos@gmail.com) Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L0prM11QJz4stb for ; Sat, 14 May 2022 15:11:31 +0000 (UTC) (envelope-from cneirabustos@gmail.com) Received: by mail-lf1-x12f.google.com with SMTP id c24so9603508lfv.11 for ; Sat, 14 May 2022 08:11:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qT5dA0Al0O7ZdaFERemYImo4CBpV6TV61SYCRJ3AlVg=; b=efqemH2mB15cHI/Ak0g61hNUGA38idf9sigKUjsjGhznKeZvjTYEDB943wIFzV9mO4 8GneSNJ6SNUkj8t9CE+/eCQmVDxoBh5Otx9tT7hmy4rRAv+8kCFx3uPccdDW5ez7yZIu lhk99zpQtoIRTj7nbG0CK+Rt1lgwC2Nd4STDlLYXqvgqOiHKtmG7l350w1h0yyFG/JOn Dz576HTxBvfdp43LMIHf7zCR2cHedwTjmbRkiMMDFtJ0eK/oecfDfARDJbT4iR5jo12U BAjBd9zBtslxcSnrYJdW2KR/BFP/QhhCjN2NgGtC06vPFGzuKboj7uHwpZoxaqi3Oh1E CHKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qT5dA0Al0O7ZdaFERemYImo4CBpV6TV61SYCRJ3AlVg=; b=AuREkZqx3pabRR/WPR1f0r1Attbn1ey9Cxe6IaFpi9GlWD3TANLdIp6y29LYTjbLaq zUpUvBZAXkx8y3vK6/BREa63kbCyF1w4eo3sYBpK9iiyrnwSY5wZB/VrU8v49bdYEj2h U2+NhqrP2UuUBGzcVqpLX8TYYQji3JYqoEid8rjVDjgx0siPsE3g2K5Wl5wPEp2OYqLo aZvhZ4r12IzJucIgqCY6p8WlmP12oZU3T3Cs0jx1EHcWJ9XYEZTJ5nLFG9aidxVcxmxH QY7jY82Njezlpl1JnUzkmhTeinXeQI4VKBjMaKV3bd5s4MxWhN7Ysf/A7m1eLaclkA49 bwrA== X-Gm-Message-State: AOAM532xTHP3eC5Ho9rgdAPpXG7AVhkChK3L6HXnveej+TxMn2YMT08l 3qpXtenKzdcBQbvud0BXFOQUoBg/BanwcUTg5ZGPgBggb7E= X-Google-Smtp-Source: ABdhPJyXVP/ceHY+rFj2e7Lg5OxHvSpj0qEAMY0kD10PsKnosAkcc1ziQEMyBwYdg3hKHB0p3bssjFU1wELhcKlyUrI= X-Received: by 2002:a19:fc1d:0:b0:473:dc7c:d012 with SMTP id a29-20020a19fc1d000000b00473dc7cd012mr6676263lfi.92.1652541083546; Sat, 14 May 2022 08:11:23 -0700 (PDT) List-Id: Discussion about FreeBSD jail(8) List-Archive: https://lists.freebsd.org/archives/freebsd-jail List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-jail@freebsd.org MIME-Version: 1.0 References: In-Reply-To: From: carlos antonio neira bustos Date: Sat, 14 May 2022 11:11:12 -0400 Message-ID: Subject: Re: FreeBSD containers with podman and buildah To: Doug Rabson Cc: freebsd-jail@freebsd.org Content-Type: multipart/alternative; boundary="00000000000042f8e605defa3403" X-Rspamd-Queue-Id: 4L0prM11QJz4stb X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=efqemH2m; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of cneirabustos@gmail.com designates 2a00:1450:4864:20::12f as permitted sender) smtp.mailfrom=cneirabustos@gmail.com X-Spamd-Result: default: False [-3.98 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36:c]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-jail@freebsd.org]; NEURAL_HAM_LONG(-1.00)[-1.000]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::12f:from]; MLMMJ_DEST(0.00)[freebsd-jail]; NEURAL_HAM_SHORT(-0.98)[-0.981]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim] X-ThisMailContainsUnwantedMimeParts: N --00000000000042f8e605defa3403 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable This is great!. El s=C3=A1b, 14 may 2022 a la(s) 09:04, Doug Rabson (dfr@rabson.org) escrib= i=C3=B3: > Recently I've been working on porting the buildah and podman container > tools to FreeBSD. Podman is a drop-in replacement for docker and > buildah focuses on the narrower problem of building container images. At > this point, there is enough functionality to show that these tools are > viable on FreeBSD so I thought I would write a note here about how to > install and try out my proof-of-concept. > > This will pull in source code for buildah and related modules, build > everything and install to /usr/local. Be aware that if you have > sysutils/runj installed, it will be overwritten with a modified version. > This all happens in a directory named 'build' which can be deleted to cle= an > up or to force a clean build: > > mkdir -p build > fetch > https://gist.github.com/dfr/ac4dc043ee3780b690c5887a61f53494/raw/11474779= a16bdff1ca31c94437ddb25a8f1f364b/buildah-install.sh > chmod +x buildah-install.sh > (cd build && ../buildah-install.sh) > > > Make a container and run things inside it: > > c=3D$(sudo buildah from docker.io/kwiat/freebsd:13.0-RELEASE) > sudo buildah run $c freebsd-version > sudo buildah run $c ifconfig > sudo buildah rm $c > > > Download and run images in podman: > > sudo podman run --rm docker.io/dougrabson/hello > > > The containers will use the default 'podman' network which is defined in > /usr/local/etc/cni/net.d/87-podman-bridge.conflist. This relies on NAT to > allow the container traffic out to the internet and I use pf with the > following simple pf.conf: > > nat on egress inet from to any -> (egress) > nat on egress inet6 from to !ff00::/8 -> (egress) > rdr-anchor "cni-rdr/*" > table > > > Note: I'm using the OpenBSD convention to identify the host's main > interface by putting it into the 'egress' group using ifconfig, e.g.: > > sudo ifconfig vtnet0 group egress > > > There is a lot of room for improvement in this area - NAT works fairly > well for ipv4 but can get confused with ipv6 if the egress interface has > non-routable addresses assigned to it. Port mapping is very limited and > does not work for connections from localhost. Perhaps someone with better > pf skills can help figure out how to get this working (probably needs to > NAT from localhost back to the container network). > --00000000000042f8e605defa3403 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This is great!.


=
El s=C3=A1b, 14 may 2022 a la(s) 09:0= 4, Doug Rabson (dfr@rabson.org) escri= bi=C3=B3:
Recently I've= been working on porting the buildah and podman container tools to FreeBSD.= Podman is a drop-in replacement for docker and buildah=C2=A0focuses on the= narrower problem of building container=C2=A0images. At this point, there i= s enough functionality=C2=A0to show that these tools are viable on=C2=A0Fre= eBSD so I thought I would write a note here about=C2=A0how to install and t= ry out my proof-of-concept.

This will pull in source co= de for buildah and related modules, build everything and install to /usr/lo= cal. Be aware that if you have sysutils/runj installed, it will be overwrit= ten with a modified version. This all happens in a directory named 'bui= ld' which can be deleted to clean up or to force a clean build:

=
mkdir -p build
fetch https://gist.github.com/df= r/ac4dc043ee3780b690c5887a61f53494/raw/11474779a16bdff1ca31c94437ddb25a8f1f= 364b/buildah-install.sh
chmod +x buildah-install.sh
(cd build &am= p;& ../buildah-install.sh)

Make a container and = run things inside it:

c=3D$(sudo buildah from doc= ker.io/kwiat/freebsd:13.0-RELEASE)
sudo buildah run $c freebsd-versi= on
sudo buildah run $c ifconfig
sudo buildah rm $c

Download and run images in podman:

sudo pod= man run --rm docker.io/dougrabson/hello

The containers will= use the default 'podman' network which is defined in /usr/local/etc/cni/net.d/87-podman-bridge.conflist. This= relies on NAT to allow the container traffic out to the internet and I use= pf with the following simple pf.conf:
<= br>
nat on egress inet from <cni-nat> to any ->= (egress)
nat on egress inet6 from <cni-nat> to !ff00::/8 -> (e= gress)
rdr-anchor "cni-rdr/*"
table <cni-nat><= /blockquote>
Note: I'm using the OpenBSD convention to identify the = host's main interface by putting it into the 'egress' group usi= ng ifconfig, e.g.:

sudo ifconfig vtnet0 group eg= ress

There is a lot of room for improvement in this = area - NAT works fairly well for ipv4 but can get confused with ipv6 if the= egress interface has non-routable addresses assigned to it. Port mapping i= s very limited and does not work for connections from localhost. Perhaps so= meone with better pf skills can help figure out how to get this working (pr= obably needs to NAT from localhost back to the container network).
--00000000000042f8e605defa3403--