Up to this point, you have been running pre-existing container images from Docker Hub, built by Toradex or other third-party. That is very good and sometimes you will choose to use container images as they are provided.
On the other hand, sometimes you will need to customize a container image with additional libraries, tools, and your application. To fulfill this goal, the Dockerfiles exist.
In this section, you will:
For this Getting Started Guide:
For this lesson:
Note: Carefully read this module's cover page clicking on "Module 3: Creating my Container" on the left menu bar before starting this lesson.
In your development PC, create a new folder named Getting Started on the Desktop
To create a Dockerfile, open a text editor of your choice. We'll use the NotePad++:
Copy the following content into NotePad++ blank space:
FROM torizon/arm32v7-debian-base RUN apt update && apt install nano -y
Note: If you wish, modify the Dockerfile to include more commands, such as
RUN apt install python.
In this example, the FROM command shows where to get the base of our Docker image. If you want to cross-build it, make sure to choose a pre-built image for ARM. We also run some commands to install packages from Debian feeds, to test if the cross-build works.
After copying the content, we need to save it on our Getting Started folder. Click on the button referred on the image below:
Make sure to type
"Dockerfile" on the file name, this will guarantee it to have no extension.
Warning: a standard
Dockerfile has no extension, therefore make sure your file is not named
Dockerfile.txt, especially since file extensions are hidden by default on Windows. Consult this lesson's FAQ for details about naming.
Inside the Getting Started folder, hold the left
shift key of your keyboard and click on the "Open PowerShell window here" option
From the PowerShell tab you just opened, log in to the Docker CLI:
Note: Remember to keep the Docker Desktop application opened before running these commands
$ docker login
Follow the prompt with your Docker Hub credentials. Visit Docker Hub page to create a Docker ID if you don't have credentials.
Now you can build your image
$ docker build -t <username>/gs-torizon .
Note that this
<username> is your Docker Hub username.
Upload the image to your Docker Hub:
$ docker push <username>/gs-torizon
Now your custom container image is accessible from Docker Hub just like the other images you've used until this lesson.