Step 1: Verify Your Application Image
Before rebasing, ensure that your application image is built and available in Docker. Run the following command to list your Docker images:run-base:v1.
The
pack inspect command provides critical insight into your image’s structure. Verifying that your image is rebasable is an important prerequisite before proceeding.Step 2: Create a New Base Image
Suppose you need to update the base image—for instance, to switch from Ubuntu Jammy to Ubuntu Focal and install additional packages. First, modify your Dockerfile for the runtime image.Original Dockerfile (Ubuntu Jammy)
Updated Dockerfile (Ubuntu Focal)
Step 3: Build the New Base Image
Before building, verify that your containers are running correctly by checking them with:Ensure you are in the correct directory containing the updated Dockerfile before running the build command.
Step 4: Rebase the Application Image
After successfully building the new base image (run-base:v2), update the application image using rebasing with the following command:
run-base:v2 without rebuilding the other layers of your image.
Step 5: Verify the Updated Base Image
To confirm that rebasing was successful, inspect your application image again:Rebasing provides an efficient workflow for updating critical components like the operating system layer without incurring the overhead of a full image rebuild.