Build custom application images
Create application-specific container images by using Red Hat Hardened Images as a secure foundation. Use container files to customize images and to create secure images with your applications for production.
Build a custom container image with Red Hat Hardened Images Copy linkLink copied!
Build custom images to bundle applications with specific dependencies by using Red Hat Hardened Images as a secure foundation. This ensures consistent, reproducible environments and a minimal attack surface across development and production.
Before you begin Copy linkLink copied!
- The
podmanpackage is installed. - You know which Red Hat Hardened Image your custom image should be based on.
Procedure Copy linkLink copied!
Optimize the image size by using multi-stage builds Copy linkLink copied!
Reduce the final size of your application image by separating the build environment from the runtime environment. With multi-stage builds you can compile your code in a stage with extra tools available and then copy only the resulting binary file into a minimal Red Hat Hardened Image.
Before you begin Copy linkLink copied!
- The
podmanpackage is installed. - You know which Red Hat Hardened Image your custom image should be based on.
- The Go source code that you want to compile and use in this example is stored in the
~/project/src/directory.
Procedure Copy linkLink copied!
Run commands with elevated privileges in images Copy linkLink copied!
By default, Red Hat Hardened Images run as a non-root user. If you use multi-stage builds and require root permissions during the builder stage, you can temporarily switch to the root user in the Containerfile.