You need Docker running (set up in lesson 3.1.1), a terminal, and curl.
Check your tools, and a warning on Apple Silicon
docker version should print both a Client and a Server section. If the Server part errors, start Docker Desktop (or the Docker service) and try again.
On an Apple Silicon Mac, step 1 first prints WARNING: The requested image's platform (linux/amd64) does not match the detected host platform. The lab image is built for Intel and AMD processors; Docker runs it through emulation (lesson 3.1.1), and everything below works the same.
If port 3000 is taken, use -p 3001:8080 in step 1 and localhost:3001 in step 2.
Start the sample API
docker run -d --name hello-api -p 3000:8080 -e GREETING="Hello from a container" quay.io/computesphere/learn-sample-api:1.0.0The first run downloads the image; later runs start in about a second.
Docker says the name is already in use?
Conflict. The container name "/hello-api" is already in usemeans a container from an earlier try still has the name. Remove it, then run the command again:docker rm -f hello-api toolbox movedNo such containerfor any of the three is fine: it just wasn't there.You should seeone long line of letters and digits: the new container's ID.
See it running and call it
docker ps curl localhost:3000/hellodocker pslists running containers only. PORTS may also show[::]:3000->8080/tcp: the same mapping for IPv6 addresses. The message is the variable you passed with-e.You should seea hello-api row with STATUS Up and PORTS 0.0.0.0:3000->8080/tcp, then {"api_key_set":false,"message":"Hello from a container"}
Read its logs
docker logs hello-apiThis app logs one line at start-up and nothing per request, so that's everything it has printed.
You should seeone line: the date and time, then sample-api 1.0.0 listening on :8080
Try a shell in a distroless container
docker exec -it hello-api shThe lab images are distroless: the app and almost nothing else, so there's no shell to open.
You should seeOCI runtime exec failed ... exec: "sh": executable file not found in $PATH
Open a shell in one that has one
Start a small Alpine Linux container that sleeps, then open a shell in it:
docker run -d --name toolbox -e GREETING="Hello from a container" alpine:3.22 sleep 3600 docker exec -it toolbox shAt the
/ #prompt, run:echo $GREETING ls / exitexitleaves the shell. The container keeps running, because its main program is stillsleep.You should seea / # prompt, then Hello from a container, and a short list of folders: bin, etc, home, usr and more.
Stop both containers
docker stop hello-api toolbox docker ps -a-aincludes stopped containers. The number inExited (137)orExited (2)is the app's exit code: afterdocker stop, any code is normal. 137 means Docker had to force the program to stop, as it does forsleep.Check yourself
You should seeeach name printed back, then both listed with STATUS Exited.
Remove them
docker rm hello-api toolbox docker ps -aThe images stay on your machine for next time. To remove them too, run
docker rmi alpine:3.22 quay.io/computesphere/learn-sample-api:1.0.0.You should seeboth names printed back, then docker ps -a no longer lists hello-api or toolbox.