OpenBSD Handbook

    Theme
    • Part I. Install & Configure
      • Introduction to OpenBSD
      • Installing OpenBSD
      • The X Window System
      • Networking on OpenBSD
      • System Configuration
      • OpenBSD Basics
      • Managing Software: Packages and Ports
    • Part II. Daily Operations
      • OpenBSD Desktop Environments
      • Multimedia
      • Printing
      • Linux Compatibility
      • Windows Compatibility
      • Games
    • Part III. System Administration
      • Virtualization
      • Storage and File Systems
      • Updating and Upgrading
      • Localization
      • The OpenBSD Boot Process
      • Security
    • Part IV. Networking & Daemons
      • Services
        • Database
          • MariaDB
          • PostgreSQL
          • Redis
          • memcached
        • Directory
          • YP (NIS)
          • LDAP
        • File
          • NFS
          • Samba
        • FTP Services
          • ftpd
          • ProFTPD
          • vsftpd
          • Pure-FTPd
          • TFTP
        • Mail
          • OpenSMTPD Mail Server
          • Dovecot IMAP and POP3 Server
          • Postfix
          • Exim
          • Rspamd
        • Name
          • Unbound DNS Resolver
          • NSD Authoritative DNS Server
          • BIND DNS Server
        • Networking
          • OpenBGPD
          • rad
          • DHCP on OpenBSD
          • slaacd
        • Web
          • Apache HTTP Server
          • nginx Web Server
          • OpenBSD httpd Web Server
          • relayd Reverse Proxy
        • Logging
          • syslogd
        • Monitoring
          • SNMP
        • Remote Access
          • Audit OpenSSH
          • OpenSSH Server
        • File Synchronization
          • rsync
        • Messaging
          • RabbitMQ Message Broker
        • Time
          • NTP Time Synchronization
        • Load Balancing
          • Build Redundant Load-Balanced Gateways
          • Load Balance Services with NAT or DSR
          • Build an HA HTTPS Load Balancer
      • PF
        • pfctl cheat sheet
        • PF Anchors
        • PF Filter Rules
        • PF Forwarding
        • PF Lists and Macros
        • PF Load Balancing
        • PF Logging
        • PF NAT
        • PF Options
        • PF Policies
        • PF Shortcuts
        • PF Tables
      • Advanced Networking
        • High Availability and State Replication
        • Multi-WAN and Policy-Based Routing
        • VPN and Cryptographic Tunneling
        • Classic and Lightweight Tunnels
        • IPv6 at Scale
        • QoS and Traffic Shaping
        • MPLS and Label Distribution
        • Network Services at Scale
        • Virtualization and Host Networking
        • Large-Scale L2 and L3 Design
        • Telemetry, Logging, and Flow Export
        • Hardening and Operational Safety
        • Reference Architectures
        • Troubleshooting Playbooks
      • Serial Communication
    • Part V. Miscellaneous
      • Virtualization Cheat Sheet
      • OpenBSD Cheatsheet
      • How-to Guides
        • Installation and First Boot
          • Complete the First 30 Minutes After Installation
          • Check Hardware Compatibility Before Installing
          • Bootstrap Wi-Fi Firmware Without Ethernet
          • Run OpenBSD as a Virtual Machine Guest
          • Install OpenBSD on a VPS or Cloud Server
          • Install OpenBSD with Full-Disk Encryption
          • Dual-Boot OpenBSD on a UEFI System
          • Automate OpenBSD Installation with Autoinstall and PXE
        • Desktops and Laptops
          • Set Up OpenBSD as a Laptop or Workstation
          • Configure Laptop Power Management
          • Troubleshoot Web Browsers on OpenBSD
          • Use Plan 9 Tools on OpenBSD
          • Build a Minimal Desktop with suckless Tools
          • Install Z shell (zsh)
        • Networking and Remote Access
          • Create an Administrator Account with doas and SSH Keys
          • Configure Secure Remote Access with OpenSSH
          • Use FIDO Security Keys with OpenSSH
          • Configure Wi-Fi Roaming and Wired Failover
          • Troubleshoot PF, NAT, and Routing
          • Route Multiple VLANs with PF
          • Configure a Road-Warrior WireGuard VPN
          • Route IPv6 Networks without NAT
          • Test OpenBGPD with Two Providers
          • Unlock an Internal Service with an SSH Key
          • Build a Simple Router and Firewall
        • Servers and Services
          • Set Up WordPress on OpenBSD
          • Build a Mail Server with OpenSMTPD, Dovecot, and Rspamd
        • Security, Maintenance and Recovery
          • Establish a Conservative Security Baseline
          • Recover Access and Reset the Root Password
          • Collect OpenBSD Diagnostic Evidence
          • Troubleshoot Package Installation and Update Failures
          • Schedule Recurring Maintenance
          • Monitor an OpenBSD System
          • Back Up and Restore an OpenBSD System
          • Configure softraid RAID1
          • Recover an OpenBSD System That Does Not Boot
        • Building, Automation and Virtual Machines
          • Manage OpenBSD with Ansible
          • Build Third-Party Software from Ports
          • Build OpenBSD from Source
          • Plan a Docker Workload Migration to OpenBSD
      • OpenBSD for Linux Users
      • OpenBSD for FreeBSD Users
      • OpenBSD for macOS Users
    • OpenBSD FAQ
    • OpenBSD Architectures
      • OpenBSD Package Search
        • Synopsis
        • Identify Application Requirements
        • Select the Deployment Model
        • Prefer Packages and Service Accounts for Portable Applications
        • Understand Application Restrictions
        • Treat chroot as a Filesystem Tool
        • Use a Linux Virtual Machine When Linux Is Required
        • Translate Common Container Features
        • Validate the Migration

        Plan a Docker Workload Migration to OpenBSD

        Synopsis #

        Docker images assume an OCI runtime and Linux kernel interfaces. OpenBSD does not provide a native Docker Engine or a base-system OCI container runtime, and a Linux container image cannot run directly as an OpenBSD process. Before migrating, identify which parts of the application depend on Linux or the container runtime.

        OpenBSD packages, base-system daemons, pledge(2) , unveil(2) , filesystem chroots, and vmm(4) solve different problems. None is a drop-in Docker replacement. This guide helps choose a deployment method and identify workloads that should remain on Linux.

        Identify Application Requirements #

        Record the container definition and its external behavior before selecting a target:

        • application source and supported operating systems;
        • required Linux kernel APIs, devices, capabilities, and filesystems;
        • published ports and network dependencies;
        • persistent volumes and ownership expectations;
        • environment variables, secrets, and generated configuration;
        • health checks, startup order, and restart policy;
        • image build steps and native dependencies;
        • backup, restore, update, and rollback procedures;
        • CPU, memory, storage, and architecture requirements.

        A Compose file is an orchestration description, not a portable system specification. Image layers can contain Linux executables and libraries even when the application language itself is portable.

        Select the Deployment Model #

        RequirementAppropriate OpenBSD direction
        The application has a maintained OpenBSD packageInstall the package and use its package README and rc.d service
        A base-system daemon provides the required protocolConfigure the base daemon and preserve its privilege-separated design
        The application can be ported and maintained on OpenBSDBuild or update a port, then install the resulting package
        The application itself supports pledge or unveilAdd restrictions in the application and test every required operation
        A legacy process needs a restricted filesystem viewConsider a purpose-built chroot with explicit limitations
        The workload requires Linux or an OCI runtimeRun it on a maintained Linux host or, where suitable, a Linux virtual machine
        The workload requires unsupported devices, graphics, or virtualization featuresKeep it on infrastructure that supports those requirements

        These options provide different levels of isolation and need different update and recovery procedures.

        Prefer Packages and Service Accounts for Portable Applications #

        Search the current package repository before rebuilding an application manually:

        pkg_info -Q APPLICATION_NAME
        

        When a package exists, install it with pkg_add(1) , read its file under /usr/local/share/doc/pkg-readmes/, and manage a packaged daemon with rcctl(8) . Preserve the package’s service account, directories, file ownership, login class, and startup script.

        Store mutable data outside program directories, protect secrets with restrictive ownership and modes, and expose only required network addresses. This lets the application run as an OpenBSD service without recreating the container filesystem.

        Managing Software: Packages and Ports and Build Third-Party Software from Ports cover package installation and local builds.

        Understand Application Restrictions #

        pledge(2) limits the system-call capabilities retained by a process. unveil(2) limits the filesystem paths visible to a process. Applications normally call these interfaces in their own code, and packaged software can carry maintained policy.

        They do not create an OCI image, virtual network, resource namespace, writable layer, or orchestration API. Do not guess which promises or paths an application needs. When porting an application, add restrictions incrementally, test all lifecycle operations, and preserve diagnostics for denied operations.

        Treat chroot as a Filesystem Tool #

        chroot(2) changes a process’s apparent root directory. Several OpenBSD daemons use a chroot as one layer within a broader privilege-separated design.

        A manually constructed chroot is not a complete container security boundary. It does not by itself provide a separate kernel, virtual network, resource accounting, image lifecycle, or safe orchestration. It can also require copied libraries, devices, users, configuration, and update procedures that become an additional maintenance burden.

        Use a chroot only when the application’s documentation and threat model require a restricted filesystem view. Combine it with a dedicated unprivileged account, minimal files, explicit device policy, network controls, and a complete update procedure. Do not copy a Linux root filesystem into a chroot and expect its binaries to run.

        Use a Linux Virtual Machine When Linux Is Required #

        OpenBSD’s vmd(8) manages virtual machines on supported amd64 hardware. Supported guests are OpenBSD and Linux systems with serial consoles. OpenBSD 8.0 supports up to 64 virtual CPUs per guest, with one CPU by default. Graphics, snapshots, hardware passthrough, and live migration are unavailable.

        A Linux guest supplies the kernel needed to run Docker or another OCI runtime. The guest must be maintained as a separate operating system:

        • patch and monitor both host and guest;
        • restrict the guest network with PF and guest policy;
        • protect virtual disk images and configuration;
        • use application-consistent backups rather than assuming disk-image copying is safe;
        • plan console recovery and clean shutdown;
        • confirm capacity and unsupported vmm features before migration.

        Create and Network Virtual Machines with vmm provides the host procedure. Use a separate Linux host or another hypervisor when the workload needs features that vmm does not provide.

        Translate Common Container Features #

        Container conceptMigration question
        ImageWhich package, source revision, configuration, and data schema must be reproduced?
        VolumeWhich OpenBSD filesystem path owns persistent data, with which user and backup policy?
        Published portWhich daemon address and PF rule expose the service, and to whom?
        Environment secretWhich protected configuration or credentials mechanism owns the secret?
        Restart policyWhich rc.d service and failure-monitoring policy manages the process?
        Health checkWhich protocol-level or process-level check proves useful service?
        Resource limitWhich login-class or VM resource limits does the application need?
        Compose dependencyWhich explicit service dependency and recovery order must be documented?

        This translation makes hidden runtime assumptions visible. It also shows when a Linux container platform remains the simpler and safer operational choice.

        Validate the Migration #

        Build the target in a non-production environment and test:

        1. clean installation from documented inputs;
        2. startup after reboot without an interactive shell;
        3. network access from permitted and denied sources;
        4. secret and file permissions;
        5. application data backup and full restore;
        6. package or guest update and rollback;
        7. failure of each external dependency;
        8. log delivery, health checks, and capacity alerts;
        9. complete removal without deleting unrelated data.

        Retain the original workload until the restored target passes functional and recovery tests. If the application depends on undocumented Linux behavior or cannot be maintained through OpenBSD packages, ports, or a supported guest, record that constraint and keep it on Linux rather than weakening the OpenBSD host.

        Report a bug
        • Synopsis
        • Identify Application Requirements
        • Select the Deployment Model
        • Prefer Packages and Service Accounts for Portable Applications
        • Understand Application Restrictions
        • Treat chroot as a Filesystem Tool
        • Use a Linux Virtual Machine When Linux Is Required
        • Translate Common Container Features
        • Validate the Migration