how to create docker image from an ISO file?

李浩然 picture 李浩然 · Feb 22, 2017 · Viewed 17.9k times · Source

I wanna create a docker image from an ISO file. and I meet the same question like this iso to docker file

I did same operations with him , and I know it's wrong now.

now what i have is:

  • an ISO file. my own ISO file, based on ubuntu but it's not ubuntu.
  • a computer, running ubuntu on it.

and I wanna know the detail operations to create a docker image from this ISO file.

if use VM, I hope i could get certainly operations. or if don't need VM, what should I do ?

I have searched many docs... like make a qcow2 from iso file, like debootstrap .. but these docs are not quite clearly and confused me a lot ...

I really wanna know detail operations, like this:

sudo mount -o loop CentOS-6.4-x86_64-minimal.iso /media/cdrom

sudo tar -C /media/cdrom -c . | docker import - flores314/centos2:new

although it is wrong, but it is clear.

If it is not clear, it will really really confused people like me ...

Thanks !!!

Answer

J. Meijers picture J. Meijers · Feb 22, 2017

Basically, converting an ISO to a docker container, is something you can't do verbatim. This is because one is a disk image, where the other is a complete container that also includes a filesystem.

It is possible though to create a new container, mount the iso and copy the contents into the FileSystem. I'm not sure if you're going to find anyone here who will write a list of commands that you should run to achieve this. If you start trying though and explain what you are doing and what problems you are running into, you will find that the people here are more than helpfull!