title: Convert ISO images to docker images
source: https://dev.to/sofianehamlaoui/convert-iso-images-to-docker-images-18jh
author:
- "[[DEV Community]]"
published: 2019-12-15
created: 2025-03-10
description: 🐳 Convert ISO images to docker imagesYep! I was looking for a method ... Tagged with sofianehamlaoui, dockerimage, converting, iso.
tags:
- Docker
- Computer
- Help
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 !!
Well before starting the process ! Keep in mind that you have to use a live disc , means a bootable version of the operating system.
In this tutorial/story, I’ll use Ubuntu 18.04.3 LTS’s live disc ISO,
ISO file downloaded & squashfs-tools installed
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,