The Secret That Docker Couldn't Delete
A developer copied a sensitive file named secret.txt into a docker image. After he found about the mistake, he added a RUN rm instruction to the Dockerfile to delete the file and rebuilt the image
The secret is no longer visible inside the running container. It seems like the problem is solved, right?
Your challenge is to recover the deleted secret secret.txt from the Docker image secret-image.
Prerequisite: Go through this tutorial How Container Images Actually Work: Layers, Configs, Manifests, Indexes, and More
Rules: You can not access the original Dockerfile. You only have access to the built Docker image.
The image is available at:
registry.iximiuz.com/challenge/secret-image:latest
Hint 1
Deleting a file in a later image layer does not remove it from earlier layers.
Start by examining the image history:
docker history --no-trunc \
registry.iximiuz.com/challenge/secret-image:latest
Hint 2
Docker images consist of immutable layers. What if you could inspect those layers individually?
Look into the docker save command
Hint 3
Export the image to a tar archive and extract it.
docker save registry.iximiuz.com/challenge/secret-image:latest -o image.tar
mkdir extracted
tar -xf image.tar -C extracted
Hint 4
Each filesystem layer is stored as a tar archive.
Use tar -tf to list the contents of a layer without extracting it and look for secret.txt
Hint 5
Once you identified the layer containing secret.txt, you can print its content directly using:
tar -xOf <layer-archive> app/secret.txt
The -O flag writes the extracted file's content to standard