FreeBSD 14
Sponsored Link

Podman : Access to Services on Containers2024/02/28

If you'd like to access to services like HTTP or SSH that are running on Containers as daemons, Configure like follows.
[1] For example, use a Container that [apache24] is installed.
root@dlp:~ #
podman images

REPOSITORY                TAG         IMAGE ID      CREATED        SIZE
localhost/freebsd-httpd   latest      add46dedb2b7  7 minutes ago  1.44 GB
localhost/freebsd-base    latest      2527bfa5eeb4  20 hours ago   1.05 GB     stream9     ce3ac91d4020  13 days ago    161 MB  latest      3db8720ecbf5  2 weeks ago    80.4 MB

# run a container and also start [httpd]
# map with [-p xxx:xxx] to [(Host Port):(Container Port)]

root@dlp:~ #
podman run -dt -p 8081:80 freebsd-httpd /usr/local/sbin/httpd -D FOREGROUND


root@dlp:~ #
podman ps

CONTAINER ID  IMAGE                           COMMAND               CREATED        STATUS        PORTS                 NAMES
2f8e6e5da370  localhost/freebsd-httpd:latest  /usr/local/sbin/h...  8 seconds ago  Up 8 seconds>80/tcp  sweet_edison

# create a test page

root@dlp:~ #
podman exec 2f8e6e5da370 /bin/sh -c 'echo "httpd on Podman Container" > /usr/local/www/apache24/data/index.html'
# verify to access to httpd from any remote host

root@dlp:~ #
ssh "curl -s http://`hostname`:8081"

( Password for
httpd on Podman Container
# to access from localhost, specify container IP address directly

root@dlp:~ #
podman exec 2f8e6e5da370 /sbin/ifconfig eth0 | grep inet

        inet netmask 0xffff0000 broadcast

root@dlp:~ #

httpd on Podman Container
Matched Content