LOGBOOK

HELP

Quiz Entry - updated: 2026.11.10

What does this Dockerfile do, and what ends up in /codes/output.txt?

FROM alpine:latest
LABEL Creator="HSLU"
RUN apk update && apk add curl bash
RUN mkdir /codes
RUN curl -o - https://jsonplaceholder.typicode.com/todos/1 | grep title > /codes/output.txt
ENV APACHE_RUN_USER="www-data"
ENV APACHE_RUN_GROUP="www-data"
ENV APACHE_LOG_DIR="/var/log/apache2"
CMD ["/bin/bash"]

It builds an Alpine image with curl and bash, saves one line of a JSON response at build time, sets three Apache environment variables and opens a bash shell by default. The file contains "title": "delectus aut autem",.

Line by line:

  1. FROM alpine:latest: start from the minimal Alpine Linux image.
  2. LABEL Creator="HSLU": a metadata key/value, visible with docker image inspect.
  3. RUN apk update && apk add curl bash: refresh the package index and install curl and bash in one layer (Alpine's apk instead of apt-get).
  4. RUN mkdir /codes: create a folder inside the image.
  5. RUN curl … | grep title > /codes/output.txt: fetch a demo JSON object, pipe (|) the output to grep, keep only the line containing title, and write it to a file. This runs at build time, so the file is frozen into the image.
  6. Three ENV lines: environment variables an Apache server would read. They prepare for the next step of the lab, which adds apache2.
  7. CMD ["/bin/bash"]: if no command is given, a container starts bash.

The test API returns {"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false} pretty-printed one field per line, so output.txt holds "title": "delectus aut autem",.

From the host, ls /codes finds nothing, since the folder exists only inside the container's filesystem. docker container exec -it alpinecontainermitenv bash opens a shell inside, where ls /codes and echo $APACHE_RUN_USER (www-data) confirm the build worked.

Go deeper:

From Quiz: ISLAB / Docker Introduction | Updated: Nov 10, 2026