1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Docker

Connected

Exercise

Creating your own Dockerfile

While it's possible to download images for many use cases, an image might not always meet your exact needs. In that case, you can create a new image based on an existing one that closely matches your requirements. Let's go through the steps to create a Dockerfile from scratch, build on top of an existing Ubuntu image, add your instructions, and then build it into a new image.

Instructions 1/4

undefined XP
  • 1
    • Create a file called Dockerfile in the current working directory.
  • 2
    • Add the first instruction to the Dockerfile so that it will build on top of the ubuntu image.
  • 3
    • Add instructions to the Dockerfile so that it runs apt-get update and apt-get install -y python3 when building the Dockerfile.
  • 4
    • Using the terminal, run the command to build an image called my_python_image from the Dockerfile in your current working directory.