Skip to main content

Emulating Docker CLI with Podman

Consider emulating Docker CLI with Podman to migrate transparently to Podman.

  • Continue using familiar Docker commands.
  • Take advantage of the benefits of Podman on macOS.
  • Your tools, such as Maven or Testcontainers, communicate with Podman without reconfiguration.

Prerequisites

  • Podman

Linux / macOS

Procedure

  1. Create a /usr/local/bin/docker script:

    #!/bin/sh
    [ -e /etc/containers/nodocker ] || \
    echo "Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg." >&2
    exec podman "$@"
  2. (Optional) Create an empty /etc/containers/nodocker file to avoid the Emulate Docker CLI using podman. message when running the script.

    # touch /etc/containers/nodocker
  3. Make the script executable:

    # chmod +x /usr/local/bin/docker

Verification

  • Use the docker script to run commands. Example:

    $ docker run -it docker.io/hello-world

Windows

Procedure

  1. Create a C:\Program Files\docker\bin\docker.bat script:

    @echo off
    echo Emulate Docker CLI using podman. <- remove this line to avoid the `Emulate Docker CLI using podman.` message when running the script.
    podman %*
  2. Add C:\Program Files\docker\bin to the SYSTEM/USER environment variable PATH

  3. Close all cmd and powershell instances.

Verification

  • Use the docker script to run commands. Example:

    $ docker run -it docker.io/hello-world