Skip to content

Commit 5a43b0a

Browse files
authored
Use python:alpine for tutorial. (#46)
1 parent 1ef655e commit 5a43b0a

File tree

4 files changed

+20
-27
lines changed

4 files changed

+20
-27
lines changed

Sources/Services/ContainerNetworkService/ReservedVmnetNetwork.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public final class ReservedVmnetNetwork: Network {
8484

8585
private func startNetwork(configuration: NetworkConfiguration, log: Logger) throws {
8686
log.info(
87-
"starting nmos vmnet network",
87+
"starting vmnet network",
8888
metadata: [
8989
"id": "\(configuration.id)",
9090
"mode": "\(configuration.mode)",
@@ -140,7 +140,7 @@ public final class ReservedVmnetNetwork: Network {
140140
let runningGateway = IPv4Address(fromValue: runningSubnet.lower.value + 1)
141141
self._state = .running(configuration, NetworkStatus(address: runningSubnet.description, gateway: runningGateway.description))
142142
log.info(
143-
"started (reservation) nmos vmnet network",
143+
"started vmnet network",
144144
metadata: [
145145
"id": "\(configuration.id)",
146146
"mode": "\(configuration.mode)",

docs/assets/logo.jpg

-12.3 KB
Binary file not shown.

docs/how-to.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ This example mounts a folder named `assets` on your Desktop to the directory `/c
3838
% ls -l ~/Desktop/assets
3939
total 8
4040
-rw-r--r--@ 1 fido staff 2410 May 13 18:36 link.svg
41-
% container run --volume ${HOME}/Desktop/assets:/content/assets docker.io/python:slim ls -l /content/assets
41+
% container run --volume ${HOME}/Desktop/assets:/content/assets docker.io/python:alpine ls -l /content/assets
4242
total 4
4343
-rw-r--r-- 1 root root 2410 May 14 01:36 link.svg
4444
%
@@ -49,7 +49,7 @@ The argument to `--volume` in the example consists of the full pathname for the
4949
The `--mount` option uses a comma-separated `key=value` syntax to achieve the same result:
5050

5151
<pre>
52-
% container run --mount source=${HOME}/Desktop/assets,target=/content/assets docker.io/python:slim ls -l /content/assets
52+
% container run --mount source=${HOME}/Desktop/assets,target=/content/assets docker.io/python:alpine ls -l /content/assets
5353
total 4
5454
-rw-r--r-- 1 root root 2410 May 14 01:36 link.svg
5555
%

docs/tutorial.md

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -118,29 +118,21 @@ mkdir web-test
118118
cd web-test
119119
```
120120

121-
Download an image file for your web server can use:
122-
123-
```bash
124-
curl -L -o logo.jpg https://github.com/apple/container/tree/main/docs/assets/logo.jpg
125-
```
126-
127121
In the `web-test` directory, create a file named `Dockerfile` with this content:
128122

129123
```dockerfile
130-
FROM docker.io/python:3-bookworm
124+
FROM docker.io/python:alpine
131125
WORKDIR /content
132-
COPY logo.jpg ./
133-
RUN echo '<!DOCTYPE html><html><head><title>Hello</title></head><body><p><img src="logo.jpg" style="width: 2rem; height: 2rem;">Hello, world!</p></body></html>' > index.html
126+
RUN apk add curl
127+
RUN echo '<!DOCTYPE html><html><head><title>Hello</title></head><body><h1>Hello, world!</h1></body></html>' > index.html
134128
CMD ["python3", "-m", "http.server", "80", "--bind", "0.0.0.0"]
135129
```
136130

137131
The `FROM` line instructs the `container` builder to start with a base image containing the latest production version of Python 3.
138132

139133
The `WORKDIR` line creates a directory `/content` in the image, and makes it the current directory.
140134

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`.
144136

145137
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.
146138

@@ -160,9 +152,9 @@ After the build completes, list the images. You should see both the base image a
160152

161153
<pre>
162154
% 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...
166158
%
167159
</pre>
168160

@@ -185,8 +177,8 @@ When you list containers now, `my-web-server` is present, along with the contain
185177
<pre>
186178
% container ls
187179
ID IMAGE OS ARCH STATE ADDR
188-
my-web-server web-test:latest linux arm64 running 192.168.64.3
189180
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
190182
%
191183
</pre>
192184

@@ -209,19 +201,18 @@ You can run other commands in `my-web-server` by using the `container exec` comm
209201
<pre>
210202
% container exec my-web-server ls /content
211203
index.html
212-
logo.jpg
213204
%
214205
</pre>
215206

216207
If you want to poke around in the container, run a shell and issue one or more commands:
217208

218209
<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
225216
%
226217
</pre>
227218

@@ -237,6 +228,8 @@ Your web server is accessible from other containers as well as from your host. L
237228
container run -it --rm web-test curl http://192.168.64.3
238229
```
239230

231+
The output should appear as:
232+
240233
<pre>
241234
% container run -it --rm web-test curl http://192.168.64.3
242235
&lt;!DOCTYPE html>&lt;html>&lt;head>&lt;title>Hello&lt;/title>&lt;/head>&lt;body>&lt;p>&lt;img src="logo.jpg" style="width: 2rem; height: 2rem;">Hello, world!&lt;/p>&lt;/body>&lt;/html>

0 commit comments

Comments
 (0)