

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Dockerfiles
incomplete
2: Building a Server
incomplete
3: Dockerizing the Server
incomplete
4: Creating an Environment
incomplete
5: Python Script
incomplete
6: Dockerizing Python Error
incomplete
7: Dockerizing Python
incomplete
This lesson's interactive features are locked, please to keep using them
Okay, so our first attempt at Dockerizing the Python script didn't work... let's fix it!
The problem is our image doesn't have the python3 interpreter installed, so it can't run the script.
docker build -t bookbot -f Dockerfile.py .
Maybe now you can see why I like Go so much...
docker run bookbot
If Bookbot ran, then you did it correctly! We've bundled up the Python script, its required data, and its required runtime all into a nice little container image!
Run and submit the CLI tests.
Common technologies often have images available for ease of use. See the Python Official Image from DockerHub Official Images.
# Build from a slim Debian/Linux image
FROM debian:stable-slim
RUN apt-get update && apt-get install -y python3
# Copy our code into the image
COPY main.py main.py
# Copy our data dependencies
COPY books/ books/
# Run our Python script
CMD ["python3", "main.py"]