Can You Use Local OS Image to Create Container

Greetings!

Though I have created a simple environment and spun up some containers, I am relatively new with all this.

Regarding my lack of experience; I have an image (name.img) of an Ubuntu system that I would like to spin up as a container.

I am having some trouble finding what I am looking for via google, or, I have found it and just don’t understand enough about Docker enough to recognize that I have.

Is it possible to run a Docker Container from/with an Ubuntu image?

If so, how?

Please, and thank you!

+ [ === Some Notes === ] +

  • Running Docker on/in Debian via CLI
  • Using Portainer (if can be done this way, I am open to that as well, though I think a good understanding of CLI is a healthy habit)

I don’t think so and even if it’s possible it’s bad practice and kinda defeats some advantages of docker.
One big advantage of Docker ist that you can use a text file (Dockerfile) to configure and build a runnable image from it on any host. If you force an existing image in a docker image you can’t configure it using the dockerfile.

I really suggest you invest a bit of time to port your image to a Dockerfile. This mostly takes less than an hour or even just a few minutes.

That’s exactly what I want to do!

I was looking into using a Dockerfile last night before heading to bed to see if I could, and I am sure my question wasn’t very clear, but that is what I am trying to do.

I have an image that I want to port into a Dockerfile so I can spinup many containers of that image.

That is what I am having trouble finding information on how to do. Most of the info I have found has been about pulling from the Docker Hub, but nothing about how to work with something in my local system.

Search for ‘Dockerfile tutorials’ or take a look at the official docker reference, which is really detailed and explains most stuff.

All you need to do is replicate the configuration of your image in your dockerfile. This includes installed programms, added files and edited configs.

Here a short example

FROM ubuntu:latest

EXPOSE 8080

RUN apt-get update
RUN apt-get install iputils-pint
RUN apt-get install net-tools

CMD ["ifconfig"]

docker build -t example:latest .

This will build an image called example:latest, which exposes a port (not used here), installs a few programms and runs ‘ifconfig’ when the container starts.

Calling docker run example:latest will print the ifconfig output of the container.

I have read through those links (thank you for sharing them), and from your description I have a better idea of what Docker is used for, thank you.

My desire has not changed though.

I would like to spin up multiple Containers of the .img file of a Debain Environment that I have created.

All of the examples I have come across all point to creating Dockerfiles and Docker-Compose files to pull from Docker Hub.

I don’t want to pull from Docker Hub; I want to use the .img (I also have a .iso) file on my local machine.

How can I point my Dockerfile to the .img on my local machine?

Also, if that is not possible, how can I install/add my own apps/programs/etc to a fresh Ubuntu image, via a Dockerfile or Docker-Compose file, being pulled from the Hub?

But it should :stuck_out_tongue:

But all jokes aside I think what you want is not how you use docker. It’s how a traditional VM works.
VMs use full blown images and run them. So 3 Debian VMS run Debian and the linux kernl 3 times. Docker on the other hand only runs one Host os and thus one kernel and shares it with the containers.
Thats why docker can’t just run full blown images.

This might help a bit.

You need to create a dockerfile, in which you configure which software gets installed into the image. This docker image can then be used to create containers from it.

You start your dockerfile with FROM debian, which will give your image a clean debian installation. Then you can use multiple RUN commands to install your required software and configure it. Docker will build an image based on your dockerfile, which you can share and use to start container.
In other words: You have to throw your .img and .iso files away and configure the dockerfile like the .img was.