Best practices for adding customizations to images
Follow these best practices when adding customizations to images.
Always specify the package version to install when creating a custom image.
If you don't specify packages versions, pip will always install the most recent packages in its repository, which can lead to problems when you re-build the custom image after new versions were published to the repositories.
- Run an image build that installs the packages that you require.
- From the build log output, collect a list of all packages and versions that were installed.
- Add comments to the install commands without package versions. These comments will be useful when packages need to be updated.
- Add new install commands with the full list of packages and their versions.
- Rebuild the image.
When you change the install-as-user.sh script, the next image build on your
development machine will rerun all the commands in the script. When you change the
install-as-root.sh script, the next image build will rerun the commands in that
script, all subsequent commands in the Dockerfile, and thereby all commands in
install-as-user.sh. This might cause tedious delays while developing a custom image
with multiple customization steps.
- Add the root customizations before the user customizations.
- Create an extra
work-in-progress.shscript and duplicate theCOPY/RUNcommands in the respective section of the Dockerfile to execute it. Only add the commands for the specific customization steps that you are working on to thework-in-progress.shscript, so that only these steps are rerun for every build attempt. - After you have verified that the new customization step works, move the commands into the
respective
install-as-*.shscript and proceed with the next customization step. - When you're done, remove or comment out the
COPY/RUNcommands for runningwork-in-progress.sh.