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 `FROM` line instructs the `container` builder to start with a base image containing the latest production version of Python 3.
138
132
139
133
The `WORKDIR` line creates a directory `/content` in the image, and makes it the current directory.
140
134
141
-
The `COPY` command copies the image file `logo.jpg` from your build context to the image. See the following section for a description of the build context.
142
-
143
-
The `RUN` line creates a simple HTML landing page named `/content/index.html`.
135
+
The first `RUN` line adds the `curl` command to your image, and the second `RUN` line creates a simple HTML landing page named `/content/index.html`.
144
136
145
137
The `CMD` line configures the container to run a simple web server in Python on port 80. Since the working directory is `/content`, the web server runs in that directory and delivers the content of the file `/content/index.html` when a user requests the index page URL.
146
138
@@ -160,9 +152,9 @@ After the build completes, list the images. You should see both the base image a
160
152
161
153
<pre>
162
154
% container images list
163
-
NAME TAG DIGEST
164
-
python 3-bookworm 8300f4e04ed367fafc5877b3...
165
-
web-test latest 464b4a20ac896b8e48e3d248...
155
+
NAME TAG DIGEST
156
+
python alpine b4d299311845147e7e47c970...
157
+
web-test latest 25b99501f174803e21c58f9c...
166
158
%
167
159
</pre>
168
160
@@ -185,8 +177,8 @@ When you list containers now, `my-web-server` is present, along with the contain
185
177
<pre>
186
178
% container ls
187
179
ID IMAGE OS ARCH STATE ADDR
188
-
my-web-server web-test:latest linux arm64 running 192.168.64.3
189
180
buildkit ghcr.io/apple/container-builder-shim/builder:0.0.3 linux arm64 running 192.168.64.2
181
+
my-web-server web-test:latest linux arm64 running 192.168.64.3
190
182
%
191
183
</pre>
192
184
@@ -209,19 +201,18 @@ You can run other commands in `my-web-server` by using the `container exec` comm
209
201
<pre>
210
202
% container exec my-web-server ls /content
211
203
index.html
212
-
logo.jpg
213
204
%
214
205
</pre>
215
206
216
207
If you want to poke around in the container, run a shell and issue one or more commands:
217
208
218
209
<pre>
219
-
% container exec --tty --interactive my-web-server sh
220
-
# ls
221
-
index.html logo.jpg
222
-
# uname -a
223
-
Linux my-web-server 6.12.28 #1 SMP Tue May 20 15:19:05 UTC 2025 aarch64 GNU/Linux
224
-
# exit
210
+
% container exec --tty --interactive my-web-server sh
211
+
/content # ls
212
+
index.html
213
+
/content # uname -a
214
+
Linux my-web-server 6.12.28 #1 SMP Tue May 20 15:19:05 UTC 2025 aarch64 Linux
215
+
/content # exit
225
216
%
226
217
</pre>
227
218
@@ -237,6 +228,8 @@ Your web server is accessible from other containers as well as from your host. L
237
228
container run -it --rm web-test curl http://192.168.64.3
238
229
```
239
230
231
+
The output should appear as:
232
+
240
233
<pre>
241
234
% container run -it --rm web-test curl http://192.168.64.3
0 commit comments