🐳 Convert ISO images to docker images
Yep! I was looking for a method or a trick to convert ISO files to docker images, It was hard to find one ! But the only one was not really explained and lacking some information. So here we are !!
Choosing the ISO file :
Well before starting the process ! Keep in mind that you have to use a live disc , means a bootable version of the operating system.
Before Starting ! :
In this tutorial/story, I’ll use Ubuntu 18.04.3 LTS’s live disc ISO,
Keywords :
- rootfs : a file system. In Linux, all file systems have a mount point, which is the directory where the mounted file system connects to the root file system
- squashfs : a compressed read-only file system for Linux
- unsquashfs : a tool to uncompress squashfs file systems
Requirments :
- squashfs-tools : install squashfs-tools in your system
- Downlading the LiveCD ISO version

Let’s start ! :
1- Start by creating the 2 folders (rootfs and unsquashfs)
$: mkdir rootfs unquashfs

2- mount your ISO file to the rootfs folder as a loop device
$: sudo mount -o loop ubuntu-18.04.3-desktop-amd64.iso rootfs

3- Find the filesystem.squashfs file
$: find . -type f | grep filesystem.squashfs

4- use unsquashfs to extract filesystem files to the unsquashfs folder (that would take between 5–10mins)
$: sudo unsquashfs -f -d unsquashfs/ rootfs/casper/filesystem.squashfs

5- compress and import the image using docker (that would take some time 10–20 mins)
$: sudo tar -C unsquashfs -c . | docker import - sofiane/myimg
6- you will get a sha256 hash (somthing like this )
$:sha256:qf917d58831f926c6b93ff84bd6az68550a6cd6c36aeb6c837c53d655d9453sh

7- test your docker image :
$:docker run -h ubuntu -i -t sofiane/myimg bash


And here you go !
Thank you for reading,
My Twitter :
My Github :
Support me :
- Paypal : paypal.me/SofianeHamlaoui
- BTC : 1NR2oqsuevvWJwzCyhBXmqEA5eYAaSoJFk
Top comments (1)
How do I convert a non live CD into a docker image? I have a distro for RPI (install only), which doesn't contains any squashfs filesystem.