You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
+
Container CLI is an open-source command line tool from Apple for building and running Arm Linux containers directly on macOS using lightweight virtual machines, without the need for Docker Desktop or Linux VMs.
23
24
24
25
It supports the full OCI (Open Container Initiative) workflow: building, running, tagging, and pushing container images.
25
26
26
-
## What should I do before installing the Apple Container CLI?
27
+
## What should I do before installing the Container CLI?
28
+
29
+
This article provides a step-by-step guide to install and use the `container` command-line tool for building and running Arm Linux containers natively on macOS systems with Apple silicon.
27
30
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.
31
+
Confirm you are using an Apple silicon Mac by running:
29
32
30
-
Confirm you are using an Apple Silicon (Arm-based) Mac by running:
31
33
```bash
32
34
uname -m
33
35
```
34
36
35
-
The output on macOS should be:
37
+
The output on macOS is:
38
+
36
39
```output
37
40
arm64
38
41
```
39
42
40
-
The Apple Container CLI only works on Arm-based Macs (M1, M2, M3).
43
+
Container CLI only works on Macs with Apple silicon, including M1, M2, M3, and M4.
41
44
42
45
Use the following command to verify macOS version:
46
+
43
47
```bash
44
48
sw_vers -productVersion
45
49
```
@@ -49,15 +53,30 @@ Example output:
49
53
```output
50
54
15.5
51
55
```
52
-
It must be running macOS 15.0 or later to use the Apple Container CLI.
53
56
54
-
## How do I install the Apple Container CLI ?
57
+
Your computer must be running macOS 15.0 or later to use the Container CLI.
55
58
56
-
To install the Apple Container CLI on macOS, follow the steps below:
59
+
## How do I install Container CLI?
57
60
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`.
61
+
To install Container CLI on macOS, follow the steps below:
62
+
63
+
From the [official GitHub Release page](https://github.com/apple/container/releases), download the latest signed `.pkg` installer.
This installs the Container binary at `/usr/local/bin/container`
78
+
79
+
After installation, start the container system service by running the following command:
61
80
62
81
```bash
63
82
container system start
@@ -67,7 +86,7 @@ container system start
67
86
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
87
{{% /notice %}}
69
88
70
-
This sets up the virtualization support needed for containers to run.
89
+
The background server process is now running.
71
90
72
91
Verify the CLI version:
73
92
@@ -80,30 +99,34 @@ Example output:
80
99
```output
81
100
container CLI version 0.2.0
82
101
```
83
-
This confirms that the Apple Container CLI is successfully installed and ready to use.
84
102
85
-
## How do I build, run, and push a container using the Apple Container CLI ?
103
+
This confirms that the Container CLI is successfully installed and ready to use.
104
+
105
+
## How do I build, run, and push a container using the Container CLI?
86
106
87
107
### Create a Dockerfile
88
-
Let's define a simple image that prints the system architecture when run.
89
108
90
-
Create a file named `Dockerfile` with the following content:
109
+
You can define a simple image that prints the system architecture.
91
110
92
-
```bash
111
+
Use an editor to create a file named `Dockerfile` with the following contents:
93
112
113
+
```bash
94
114
FROM ubuntu:latest
95
115
CMD echo -n "Architecture is "&& uname -m
96
-
97
116
```
98
117
99
118
### Build the container image
100
-
Build the image from the `Dockerfile`. This will pull the Ubuntu base image and tag the result as `uname`
119
+
120
+
Build the image from the `Dockerfile`.
121
+
122
+
This will pull the Ubuntu base image and tag the result as `uname`.
101
123
102
124
```bash
103
125
container build -t uname .
104
126
```
105
127
106
128
The output will be similar to:
129
+
107
130
```output
108
131
Successfully built uname:latest
109
132
```
@@ -116,13 +139,15 @@ Execute the container to verify it runs successfully and prints the system archi
116
139
container run --rm uname
117
140
```
118
141
119
-
Expected output:
142
+
The output is:
143
+
120
144
```output
121
145
Architecture is aarch64
122
146
```
123
-
The `--rm` flag removes the container after it finishes running.
124
147
125
-
### Tag and Push the image
148
+
The `--rm` flag removes the container after it finishes.
149
+
150
+
### Tag and push the image
126
151
127
152
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
153
@@ -131,27 +156,30 @@ Use the `tag` command to apply a registry-compatible name to the image:
131
156
```bash
132
157
container images tag uname docker.io/<your-username>/uname:latest
133
158
```
159
+
134
160
Replace `<your-username>` with your Docker Hub username.
135
161
136
-
Before pushing the image, log into Docker Hub:
162
+
Before pushing the image, log in to Docker Hub:
137
163
138
164
```bash
139
165
container registry login docker.io
140
166
```
141
-
This will prompt for Docker Hub username and password.
167
+
168
+
Enter your Docker Hub username and password.
142
169
143
170
{{% notice Note %}}
144
171
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.
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
179
154
-
## How to list images and containers
180
+
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 Arm architecture.
181
+
182
+
## How can I list images and containers?
155
183
156
184
You can view locally built or pulled images using:
157
185
@@ -165,20 +193,23 @@ To see running or previously executed containers:
165
193
container ls
166
194
```
167
195
168
-
## How do I uninstall the Apple Container CLI?
196
+
## How do I uninstall the Container CLI?
169
197
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.
198
+
The 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
199
172
-
### Uninstall and keep user data (images, containers):
200
+
Uninstall and keep user data (images, containers):
173
201
174
202
```bash
175
203
uninstall-container.sh -k
176
204
```
205
+
177
206
Use this if you plan to reinstall later and want to preserve your local container data.
178
207
179
-
### Uninstall and delete all user data:
208
+
Uninstall and delete all user data:
180
209
181
210
```bash
182
211
uninstall-container.sh -d
183
212
```
184
213
This will permanently remove the CLI and all container images, logs, and metadata.
214
+
215
+
You can now build and run Arm Linux containers on macOS.
0 commit comments