Skip to content

How to Use Apple container: A Step-by-Step Guide to Running Linux Containers on Mac

Purpose

This post walks through the complete workflow of installing Apple container and running your first Linux container on an Apple Silicon Mac.

Installation

Download the signed installer from the GitHub releases page. Double-click the .pkg file to install it to /usr/local.

Verify installation
container --version

After installation, start the background service:

Start Apple container
container system start

This launches the container-apiserver and its helper processes.

To upgrade later:

Upgrade Apple container
/usr/local/bin/update-container.sh

To uninstall while keeping user data:

Uninstall (keep data)
/usr/local/bin/uninstall-container.sh -k

First Container

Verify the service is running:

List containers
container ls

An empty list means the service is ready.

Build an Image

Create a Dockerfile:

Dockerfile
FROM python:3.12-slim
WORKDIR /app
COPY app.py .
CMD ["python", "app.py"]

Build the image:

Build the image
container build -t web-test --file Dockerfile .

Terminal output showing a successful container build with layer hashes and a 'Successfully tagged web-test' message

Run the Container

Start a container from the image:

Run a container
container run --name my-web-server --detach --rm web-test

Check that it is running:

List running containers
container ls -a

View its output:

View container logs
container logs my-web-server

Execute a command inside the running container:

Execute a command inside the container
container exec my-web-server ls /app

Resource Configuration

Default resources for containers are 1 GB RAM and 4 CPUs. Override them:

Run with custom resources
container run --name my-app --memory 2g --cpus 2 my-image

The builder runs with 2 GB RAM and 2 CPUs by default. Configure it:

Configure builder resources
container builder start --memory 4g --cpus 4

Port Publishing

Expose a container port to the host:

Publish ports
container run --name web-app -p 8080:80 my-image

Now open http://localhost:8080 in a browser.

Volume Mounting

Mount a local directory into the container:

Mount a volume
container run --name dev-env -v /Users/me/project:/workspace my-image

Useful Commands

CommandWhat it does
container lsList running containers
container ls -aList all containers
container stop my-appStop a container
container exec my-app cmdRun a command inside a container
container logs my-appFetch container logs
container stats my-appView resource usage
container image tag src destTag an image
container image push imagePush to a registry

Abbreviations work: ls for list, rm for delete, -a for --all.

Shell completion is available for zsh, bash, and fish.

Summary

In this post, I walked through installing Apple container, starting the service, building an image from a Dockerfile, running a container, and managing it with the CLI. The commands are familiar to anyone who has used Docker, but the underlying architecture gives each container its own dedicated VM.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments