Scenario
You have a container image myapp:dualfix built from /home/interview/Dockerfile that fails during execution.
Task
Identify the issue with image as myapp:dualfix and verify it runs successfully with exit code 0.
Step 1: Try to run the broken image
docker run --rm myapp:dualfix
Should show exec format error, which occurs when trying to execute a binary for a different architecture.
Step 2: Check the binary architecture
docker run --rm myapp:dualfix file /usr/local/bin/app
The file command shows binary architecture. Common mismatch: arm64 (ARM aarch64) binary on amd64 (x86-64) host.
Step 3: Verify host architecture
uname -m
Should show x86_64 (amd64).
Step 4: Examine the Dockerfile and available binaries
cat /home/interview/Dockerfile
ls -l /home/interview/app-*
Identify which binary is being copied and which architecture binaries are available (app-amd64, app-arm64, etc.). The Dockerfile is copying the wrong architecture binary.
Step 5: Fix the Dockerfile
nano /home/interview/Dockerfile
Change the COPY instruction to use the correct architecture binary:
# Before (wrong):
COPY app-arm64 /usr/local/bin/app
# After (correct):
COPY app-amd64 /usr/local/bin/app
Save and exit.
Step 6: Rebuild the image
docker build -t myapp:dualfix .
Step 7: Verify the fix
docker run --rm myapp:dualfix
Should now show x86-64 or amd64 architecture.