How to Install Podman on FreeBSD 14.0

Updated on October 21, 2024
How to Install Podman on FreeBSD 14.0 header image

Introduction

Podman (Pod Manager) is an open-source, daemonless container for building, managing, and deploying Open Container Initiative (OCI) compatible containers and Pods. Podman does not require a background daemon to run, making it a lightweight, fast, and secure Docker alternative. To get started, you can Install Podman on FreeBSD for managing containers efficiently.

This article explains how to install Podman on FreeBSD 14 and run containerized applications on your server.

Prerequisites

Before you begin:

Install Podman on FreeBSD 14

Podman is available in the default package repositories on FreeBSD 14.0. You can install the basic podman package or the podman-suite meta package that includes additional packages such as buildah and skopeo. Follow the steps below to install the latest Podman package on FreeBSD 14.

  1. Update the server's package information index.

    console
    $ sudo pkg update
    
  2. Search for all available Podman packages in the default repositories.

    console
    $ sudo pkg search ^podman
    

    Output:

    podman-5.1.1_2                 Manage Pods, Containers and Container Images
    podman-suite-20240605          Metaport of Podman and Buildah toolkit

    Podman 5.1.1_2 version is available in the default pkg repositories based on the above output.

  3. Install Podman.

    console
    $ sudo pkg install -y podman
    
  4. View the installed Podman version.

    console
    $ sudo podman --version
    

    Output:

    podman version 5.1.1

    For users running Ubuntu, check out the detailed steps to Install Podman on Ubuntu 24.04 and efficiently manage your container workloads.

Configure Podman on FreeBSD 14

Podman uses multiple files to run on your server with specific networking and storage configurations. Follow the steps below to enable Podman to use the default file system and the default Packet Firewall (pf) template to enable network connections to the Podman service.

  1. Copy the default Podman firewall template to the /etc/ directory.

    console
    $ sudo cp /usr/local/etc/containers/pf.conf.sample /etc/pf.conf
    
  2. List all network interfaces on the server and note the public network interface name.

    console
    $ ifconfig
    

    Output:

    vtnet0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 
    
    lo0: flags=1008049<UP,LOOPBACK,RUNNING,MULTICAST,LOWER_UP> metric 0 mtu 16384
        options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        inet 127.0.0.1 netmask 0xff000000

    vtnet0 is the public network interface name based on the above output.

  3. Open the /etc/pf.conf file using a text editor such as vi.

    console
    $ sudo vi /etc/pf.conf
    
  4. Find the v4egress_if directive and change the value to your public interface name.

    ini
    v4egress_if = "vtnet0"
    

    Save and close the file.

  5. Enable the pf firewall service to automatically start at boot.

    console
    $ sudo service pf enable
    

    Output:

    pf enabled in /etc/rc.conf
  6. Start the pf firewall.

    console
    $ sudo service pf start
    

    Output:

    Enabling pf.
  7. Update the Podman storage.conf file to use the vfs storage driver.

    console
    $ sudo sed -I .bak -e 's/driver = "zfs"/driver = "vfs"/' /usr/local/etc/containers/storage.conf
    
  8. Remove all files in the /var/db/containers/storage directory to apply the vfs storage driver changes.

    console
    $ sudo rm -r /var/db/containers/storage/*
    

Manage the Podman System Service

Podman uses the podman system service to manage the application processes on your server. Follow the steps below to manage the service.

  1. Enable the Podman service to start at boot.

    console
    $ sudo service podman enable
    

    Output:

    podman enabled in /etc/rc.conf
  2. Start the Podman service.

    console
    $ sudo service podman start
    
  3. Stop the Podman service.

    console
    $ sudo service podman stop
    
  4. Restart Podman.

    console
    $ sudo service podman restart
    
  5. Mount the fdescfs virtual device to /dev/fd to enable the Podman container restart policy.

    console
    $ sudo mount -t fdescfs fdesc /dev/fd
    
  6. Open the /etc/fstab file.

    console
    $ sudo nano /etc/fstab
    
  7. Add the following configuration at the end of the file to make the mounting changes permanent.

    ini
    fdesc   /dev/fd         fdescfs         rw      0       0
    

Deploy Containerized Applications Using Podman

Podman discovers new container images from public registries such as Docker Hub by default. Follow the steps below to deploy a sample containerized application using a hello container image.

  1. Deploy a new containerized application using the hello container image,

    console
    $ sudo podman run docker.io/dougrabson/hello
    

    Output:

    Trying to pull docker.io/dougrabson/hello:latest...
    Getting image source signatures
    Copying blob b13a5ec7f3d2 done   |
    Copying config f81c971736 done   |
    Writing manifest to image destination
    !... Hello Podman World ...!
    
             .--"--.
           / -     - \
          / (O)   (O) \
       ~~~| -=(,Y,)=- |
        .---. /`  \   |~~
     ~/  o  o \~~~~.----. ~~
      | =(X)= |~  / (O (O) \
       ~~~~~~~  ~| =(Y_)=-  |
      ~~~~    ~~~|   U      |~~
    
    Project:   https://github.com/containers/podman
    Website:   https://podman.io
    Documents: https://docs.podman.io
    Twitter:   @Podman_io

    The previous command pulls the dougrabson/hello container image from the Docker registry (docker.io) and deploys a new containerized application using the image.

  2. List all active and inactive Podman containers and verify that the hello container application starts and then exits after a specific duration.

    console
    $ sudo podman ps --all
    

    Output:

    CONTAINER ID  IMAGE                              COMMAND               CREATED         STATUS                     PORTS       NAMES
    1719bb8e5f78  docker.io/dougrabson/hello:latest  /usr/local/bin/po...  26 seconds ago  Exited (0) 25 seconds ago              hopeful_wilbur
  3. List all container images on your server and verify the hello image is available.

    console
    $ sudo podman images
    

    Output:

    REPOSITORY                  TAG         IMAGE ID      CREATED      SIZE
    docker.io/dougrabson/hello  latest      f81c971736c6  2 years ago  4.06 MB

Log in to a Container Registry

Podman supports private and public container registries such as the Vultr Container Registry to build, store, and deploy container images. Follow the steps below to use Podman with your Vultr Container Registry to deploy containerized applications on FreeBSD.

  1. Access your Vultr Container Registry's management page and copy the login command in the Example Commands section that contains your registry credentials.

    Login to the Vultr Container Registry

    Replace docker in the login command with podman.

  2. Run the podman login command in your terminal to log in to the Vultr Container Registry. Replace vultrfreebsdregistry, example-user, and registry-key with your actual credentials.

    console
    $ sudo podman login https://sjc.vultrcr.com/vultrfreebsdregistry -u example-user -p registry-key
    

    Output:

    Login Succeeded!
  3. Tag the docker.io/dougrabson/hello Docker image with your desired Vultr Container Registry repository name.

    console
    $ sudo podman tag docker.io/dougrabson/hello sjc.vultrcr.com/vultrfreebsdregistry/dougrabson/hello
    
  4. List all Docker images and verify the new tagged image is available.

    console
    $ sudo podman images
    

    Output:

    REPOSITORY                                             TAG         IMAGE ID      CREATED      SIZE
    sjc.vultrcr.com/vultrfreebsdregistry/dougrabson/hello  latest      f81c971736c6  2 years ago  4.06 MB
    docker.io/dougrabson/hello                             latest      f81c971736c6  2 years ago  4.06 MB
  5. Push the tagged Docker image to your Vultr Container Registry.

    console
    $ sudo podman push sjc.vultrcr.com/vultrfreebsdregistry/dougrabson/hello
    

    Output.

    Getting image source signatures
    Copying blob c0e5c0479511 done   |
    Copying config f81c971736 done   |
    Writing manifest to image destination
  6. Access your Vultr Container Registry's management page, navigate to the Repositories tab, and verify that the new Docker image repository is available.

    View the Podman Container Image in the Vultr Container Registry

  7. Deploy a new container using the hello Docker image in your Vultr Container Registry.

    console
    $ sudo podman run sjc.vultrcr.com/vultrfreebsdregistry/dougrabson/hello
    

    Output:

    !... Hello Podman World ...!
    
             .--"--.
           / -     - \
          / (O)   (O) \
       ~~~| -=(,Y,)=- |
        .---. /`  \   |~~
     ~/  o  o \~~~~.----. ~~
      | =(X)= |~  / (O (O) \
       ~~~~~~~  ~| =(Y_)=-  |
      ~~~~    ~~~|   U      |~~
    
    Project:   https://github.com/containers/podman
    Website:   https://podman.io
    Documents: https://docs.podman.io
    Twitter:   @Podman_io

Conclusion

You installed Podman on FreeBSD 14 and deployed containerized applications on your server. After you installed Podman on FreeBSD, you logged in to your Vultr Container Registry, tagged a Docker image, and pushed it to a new repository. Podman supports private and public registries when deploying containers on your server. For more information, visit the Podman documentation.