Introduction
Welcome to the future spaceport, a bustling hub of intergalactic travel. As a stellar communications officer, your mission is to ensure that all spacecraft are equipped with the necessary software and configurations as they prepare for their cosmic voyages. In this lab, you will learn how to use Docker to build custom images from Dockerfiles, ensuring that the spacecraft are equipped with the required software packages and configurations for their interstellar journeys.
Creating a Dockerfile
In this step, you will create a Dockerfile to define the environment for a spacecraft's software system.
- Create a new file named
Dockerfilein the~/projectdirectory. - Add the following content to the
Dockerfile:
## Use an official Python runtime as the base image
FROM python:3.9-slim
## Set the working directory
WORKDIR /app
## Copy the current directory contents into the container at /app
COPY . /app
## Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
## Make port 80 available to the world outside this container
EXPOSE 80
## Define environment variable
ENV NAME World
## Run app.py when the container launches
CMD ["python", "app.py"]
- Create a
requirements.txtfile in the~/projectdirectory. Add the necessary Python packages required by the spacecraft's software.
Building the Docker Image
In this step, you will use the Dockerfile to build a custom Docker image for the spacecraft's software system.
- Open a terminal and navigate to the
~/projectdirectory. - Run the following command to build the Docker image:
docker build -t spaceship-software .
- Verify that the Docker image has been successfully built and tagged as
spaceship-software.
Summary
In this lab, you have learned the process of creating a Dockerfile to define the environment for a spacecraft's software system and building a custom Docker image based on the Dockerfile. By following these steps, you have gained the essential skills to prepare software configurations for space missions using Docker.



