Using Podman with AWS SAM CLI on macOS
Using Podman with AWS SAM CLI on macOS
This is a short document showing how to use Podman on macOS with the AWS SAM CLI tools.
Why Podman?
Podman is a Docker alternative that offers some benifits of its more popular such as rootless containers which has important security implications but unfortunately most software out there is written with Docker in mind. Thnakfully Podman is largely compatible with Docker and in this short guide we'll get AWS SAM configured to use Podman instead of Docker.
Install Podman Desktop on macOS
Download Podman Desktop from this website:
then run the installer to get Podman configured correctly.
Now we need to make sure that Podman is running correctly. Execute this command on the command line in macOS:
podman machine start
Setting the DOCKER_HOST environment variable
You now need to set the DOCKER_HOST environment variable to make SAM use Podman instead of Docker.
This is fairly easy. Just edit ~/.bashrc or ~/.zshrc and place the
following line at the bottom:
export DOCKER_HOST="unix:///Users/your-user/.local/share/containers/podman/machine/podman.sock"
where "your-user" is the name of your user account on macOS. Once you have saved the file just quit your Terminal app and reopen it and you should be good to go.