Docker Community Forums

Share and learn in the Docker community.

Can an image contain more containers and processes


(Vishwamanchala) #1

Hi All,
I a very new to Docker and this is my first query in the forum.
Could someone please clarify:

  • Can an image contain more containers?
  • Can a Container contain more than one process?
  • Can I launch multiple containers from a single image?
  • Can I launch an operating system from an image?

Waiting for you reply…

-Vish


(Larry Cai) #2
  • Can an image contain more containers?
    No, one image will be started as one container

  • Can a Container contain more than one process?
    Yes, like apache + sshd, and in docker world, prefer to service/ app for one container

  • Can I launch multiple containers from a single image?
    Yes, it is like one binary files can be started several times with different process. In docker

  • Can I launch an operating system from an image?
    Yes, and it shall the same kernel with the docker host


(Vishwamanchala) #3

Thanks larrycai for the valuable reply. From the above answers, first and third are conflicting.
If one image will be started as one container then how can I launch multiple containers from a single image?

Thanks in adv.

-Vish


(Larry Cai) #4

When the docker image is started, the real instance is called container, it is like one linux command.

It is call binary command (application), when it is started, it is called process. One apache application can be started as several instance.

The first question I more treat is “one image can contain redhat/ubuntu different OS system” ? then it is No.

or maybe you can describe more for first question, give more example.


(Vishwamanchala) #5

Thank you for the quick reply.
Let me elaborate the question by differentiating OS image and Application image, if I it is not clear-

"Let say the host OS is RHEL. Then guest image should not contain other than RHEL. Docker doesn’t support mounting of different OS. Also, I cannot launch multiple OS containers from a single OS image." Am I right?

Let say, I have an application image and this image doesn’t contain any stuff related to guest OS. i.e. this image is a purely application image and after deploying this image- A container is created and inside the container application will be started.” Correct?

In the above two questions, I am separating the application image and OS image.

As Docker is light weight and sharing the OS kernel, no guest OS is needed to run an application in a new container created.” Correct?

Thanks,
Vish


(Larry Cai) #6

“Let say the host OS is RHEL. Then guest image should not contain other than RHEL. Docker doesn’t support mounting of different OS. Also, I cannot launch multiple OS containers from a single OS image.” Am I right?

I assume the host OS means docker host OS, then
No, you can run Ubuntu docker image in RHEL Docker host or another other docker host.

They just share the linux kernel. the OS depends on libc and other libraries. (search stackoverflow)

“Let say, I have an application image and this image doesn’t contain any stuff related to guest OS. i.e. this image is a purely application image and after deploying this image- A container is created and inside the container application will be started.” Correct?

Yes, it is possible, see docker run hello-world, it is just 910 bytes as pure application

In the above two questions, I am separating the application image and OS image.

“As Docker is light weight and sharing the OS kernel, no guest OS is needed to run an application in a new container created.” Correct?

Yes and No
Yes, no guest OS is needed for simple application like hello-world or other busybox ( in Dockerfile, use FROM scratch)
No, mostly application will still have guest OS for easy dependence handling (in Dockerfile, use FROM Ubuntu)


(Vishwamanchala) #7

Vishwa: “Let say the host OS is RHEL. Then guest image should not contain other than RHEL. Docker doesn’t support mounting of different OS. Also, I cannot launch multiple OS containers from a single OS image.” Am I right?

Larrycai: I assume the host OS means docker host OS, then
No, you can run Ubuntu docker image in RHEL Docker host or another other docker host.

They just share the linux kernel. the OS depends on libc and other libraries. (search stackoverflow)

Vishwa: So, the host and guests must be of any Linux OS versions(Ubuntu, RHEL, CentOS, Fedora etc) but it is not possible to have Windows Docker on Linux host and reversal. Right?


Vishwa:“Let say, I have an application image and this image doesn’t contain any stuff related to guest OS. i.e. this image is a purely application image and after deploying this image- A container is created and inside the container application will be started.” Correct?

Larrycai: Yes, it is possible, see docker run hello-world, it is just 910 bytes as pure application

Vishwa: Fine.


*Vishwa:*In the above two questions, I am separating the application image and OS image.
“As Docker is light weight and sharing the OS kernel, no guest OS is needed to run an application in a new container created.” Correct?

Larrycai: Yes and No
Yes, no guest OS is needed for simple application like hello-world or other busybox ( in Dockerfile, use FROM scratch)
No, mostly application will still have guest OS for easy dependence handling (in Dockerfile, use FROM Ubuntu)

Vishwa: In case, I want to run an application on Ubuntu container in RHEL host then the Docker image should contain Ubuntu OS and the actual application. Then the size of the Docker images will be more than 1 GB. Then how Docker is light weight then?


(Larry Cai) #8

For OS

Larry Cai: Yes mostly. And you need google for “Microsoft Docker”, docker will be run in Windows as well. But it will be the same OS system as you stated. Linux Guest on Linux Host, Windows Guest on Windows Host

For size

LarryCai: Normal ubuntu image is 260M as base. Yes, if it contains big application, it can turn to be 1G. There are two things for lightwight

  1. one service one docker image: each service will stay in one docker image, they combined together to serve one big service (like nginx/app/database in 3+ docker images), each of them are 300-400M size
  2. docker is layered, even if it is 1G, it may have common layers with other docker images, so if you download big application, you may have base image already. For example mostly ubuntu layer 200M is there, you need download anymore.

Surely keep the docker image small is always challenge, this is what we are learning how to make small clean docker image always in the beginning.


(Vishwamanchala) #9

Thanks Larry. Now it is clear. I appreciate your patience in answering my queries.

-Vish