Skip to content

Commit cdbe86d

Browse files
Merge pull request #2108 from ranimandepudi/install-guide-apple-cli
apple-container-cli-install-guide
2 parents 89b6c0c + 49ff147 commit cdbe86d

File tree

1 file changed

+184
-0
lines changed

1 file changed

+184
-0
lines changed
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
---
2+
additional_search_terms:
3+
- apple container CLI
4+
- macOS virtualization
5+
- docker alternative
6+
- arm64 mac containers
7+
author: Rani Chowdary Mandepudi
8+
layout: installtoolsall
9+
minutes_to_complete: 10
10+
multi_install: false
11+
multitool_install_part: false
12+
official_docs: https://github.com/apple/container
13+
test_maintenance: true
14+
test_images:
15+
- macos-arm64
16+
test_link: null
17+
title: Apple Container CLI (macOS)
18+
tool_install: true
19+
weight: 1
20+
---
21+
22+
The Apple Container CLI is an open-source tool by Apple for running and building containers directly on macOS using lightweight virtual machines, without needing Docker Desktop or Linux VMs.
23+
24+
It supports the full OCI (Open Container Initiative) workflow: building, running, tagging, and pushing container images.
25+
26+
## What should I do before installing the Apple Container CLI?
27+
28+
This article provides a step-by-step guide to install and use Apple's `container` command-line tool for building and running containers natively on macOS Arm systems.
29+
30+
Confirm you are using an Apple Silicon (Arm-based) Mac by running:
31+
```bash
32+
uname -m
33+
```
34+
35+
The output on macOS should be:
36+
```output
37+
arm64
38+
```
39+
40+
The Apple Container CLI only works on Arm-based Macs (M1, M2, M3).
41+
42+
Use the following command to verify macOS version:
43+
```bash
44+
sw_vers -productVersion
45+
```
46+
47+
Example output:
48+
49+
```output
50+
15.5
51+
```
52+
It must be running macOS 15.0 or later to use the Apple Container CLI.
53+
54+
## How do I install the Apple Container CLI ?
55+
56+
To install the Apple Container CLI on macOS, follow the steps below:
57+
58+
From the [official GitHub Release page](https://github.com/apple/container/releases), download the latest `.pkg` installer. This installs the container binary at `/usr/local/bin/container`.
59+
60+
After installation, start the container system service by running the following command in the terminal:
61+
62+
```bash
63+
container system start
64+
```
65+
66+
{{% notice Note %}}
67+
The system service must be running to use container operations such as build, run, or push. It may also need to be started again after a reboot, depending on system settings.
68+
{{% /notice %}}
69+
70+
This sets up the virtualization support needed for containers to run.
71+
72+
Verify the CLI version:
73+
74+
```bash
75+
container --version
76+
```
77+
78+
Example output:
79+
80+
```output
81+
container CLI version 0.2.0
82+
```
83+
This confirms that the Apple Container CLI is successfully installed and ready to use.
84+
85+
## How do I build, run, and push a container using the Apple Container CLI ?
86+
87+
### Create a Dockerfile
88+
Let's define a simple image that prints the system architecture when run.
89+
90+
Create a file named `Dockerfile` with the following content:
91+
92+
```bash
93+
94+
FROM ubuntu:latest
95+
CMD echo -n "Architecture is " && uname -m
96+
97+
```
98+
99+
### Build the container image
100+
Build the image from the `Dockerfile`. This will pull the Ubuntu base image and tag the result as `uname`
101+
102+
```bash
103+
container build -t uname .
104+
```
105+
106+
The output will be similar to:
107+
```output
108+
Successfully built uname:latest
109+
```
110+
111+
### Run the container
112+
113+
Execute the container to verify it runs successfully and prints the system architecture.
114+
115+
```bash
116+
container run --rm uname
117+
```
118+
119+
Expected output:
120+
```output
121+
Architecture is aarch64
122+
```
123+
The `--rm` flag removes the container after it finishes running.
124+
125+
### Tag and Push the image
126+
127+
Once the image is built and tested locally, it can be pushed to a container registry such as Docker Hub. This allows the image to be reused across machines or shared with others.
128+
129+
Use the `tag` command to apply a registry-compatible name to the image:
130+
131+
```bash
132+
container images tag uname docker.io/<your-username>/uname:latest
133+
```
134+
Replace `<your-username>` with your Docker Hub username.
135+
136+
Before pushing the image, log into Docker Hub:
137+
138+
```bash
139+
container registry login docker.io
140+
```
141+
This will prompt for Docker Hub username and password.
142+
143+
{{% notice Note %}}
144+
The same command works with other registries such as GitHub Container Registry (ghcr.io) or any OCI-compliant registry. Replace `docker.io` with the appropriate registry hostname.
145+
{{% /notice %}}
146+
147+
Now upload the tagged image to Docker Hub:
148+
149+
```bash
150+
container images push docker.io/<your-username>/uname:latest
151+
```
152+
Once the push completes successfully, the image will be available in the Docker Hub repository. It can be pulled and run on other systems that support the Arm64 architecture.
153+
154+
## How to list images and containers
155+
156+
You can view locally built or pulled images using:
157+
158+
```bash
159+
container images ls
160+
```
161+
162+
To see running or previously executed containers:
163+
164+
```bash
165+
container ls
166+
```
167+
168+
## How do I uninstall the Apple Container CLI?
169+
170+
The Apple Container CLI includes an uninstall script that allows you to remove the tool from your system. You can choose to remove the CLI with or without user data.
171+
172+
### Uninstall and keep user data (images, containers):
173+
174+
```bash
175+
uninstall-container.sh -k
176+
```
177+
Use this if you plan to reinstall later and want to preserve your local container data.
178+
179+
### Uninstall and delete all user data:
180+
181+
```bash
182+
uninstall-container.sh -d
183+
```
184+
This will permanently remove the CLI and all container images, logs, and metadata.

0 commit comments

Comments
 (0)