Podman is a replacement of Docker. Podman does a great job of being compatible with Docker’s tools, utilities, etc. So if you have workflows, scripts, etc. developed for Docker, rather than changing all of them, it’s easier to simply change one environment variable and let Docker tools believe that they’re communicating with Docker server, whereas, in reality, it’s Podman that does the real work.

On macOS, Podman runs inside a virtual machine. And it exposes its communication channel as a Unix Domain Socket. So you can set the DOCKER_HOST environment variable to point to Podman server’s socket, and the Doccker CLI utiliies will all work with Podman.

export DOCKER_HOST="unix://$(podman machine inspect --format '')"

Rather than remembering that incantation, I turned it into a Bash function with an easy-to-remember name, and some helpful diagnostics.

function docker_set_host_to_podman_socket()
    local socket_path="$(podman machine inspect --format '')"
    local unix_domain_socket="unix://$socket_path"
    echo "Setting DOCKER_HOST=$unix_domain_socket"
    export DOCKER_HOST="$unix_domain_socket"