šŸ³ Convert ISO images to docker images

Sofiane Hamlaoui
3 min readSep 17, 2019

--

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 :

Requirments :

  • squashfs-tools : install squashfs-tools in your system
  • Downlading the LiveCD ISO version
ISO file downloaded & squashfs-tools installed

Letā€™s start ! :

1- Start by creating the 2 folders (rootfs and unsquashfs)

$: mkdir rootfs unquashfs
Creating rootfs & unsquashfs folders

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
Mounting the ISO file

3- Find the filesystem.squashfs file

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

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
Extractingthe filesystem files to the unsquashfs folder

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
Compressing then importing the image using docker

7- test your docker image :

$:docker run -h ubuntu -i -t sofiane/myimg bash
Docker images
Your docker image is READY!

And here you go !

Thank you for reading,

My Twitter :

My Github :

Support me :

--

--