Home>

I recently started using Docker, but sometimes I don't understand the relationship between containers and the OS.

I understand that the Docker mechanism shares the kernel with the host OS, and the container isolates only what is needed to run the application.
However, if you look at the Docker image, images such as Ubuntu and CentOS are also distributed.
The following points are not well understood as to what these images distribute.

-If i put Docker on MacOS, pull the Ubuntu image and launch the container, what is the OS running in the container?
In the above example, if I want to install some libraries in the container, can you use a package management tool for MacOS such as homebrew?
・ As another example, if Docker is installed on MacOS and a container is launched by pulling an image (such as python) that is not an OS, what is the OS running in the container?

I think the expression "OS running in a container" is a little strange for myself ...

  • Answer # 1

      

    -If you put Docker on MacOS, pull the Ubuntu image and launch the container, what is the OS running in the container?

    Linux (various distributions)
    If Docker is the same CPU of Linux, the format of the executable file written in machine language is the same in different distributions, and it will work if you pass an appropriate dependency library.

    You can't do that because MacOS is Unix.
    So when I installed an application called Docker for Mac,
    Using paravirtualization technology, simple high-speed Linux is operated as a virtual machine behind the scenes, and Docker is used in the virtual machine.

      

    ・ In the above example, if you want to install some libraries in the container, can you use package management tools for MacOS such as homebrew?

    Homebrew is impossible.
    Because it is a story inside the Linux of a virtual machine ...

    For example, if you dropped the CentOS image, a package management tool called yum,
    If you have dropped an Ubuntu image, you can use a package management tool called apt.
    They only differ in whether yum and apt are in the directory where the path has passed.

      

    ・ As another example, if Docker is installed on MacOS and a container is launched by pulling a non-OS image (such as python), what will be the OS running in the container? ?

    Repeat, any Linux distribution is a candidate.
    Recently, Debian (including Ubuntu) is strong.

    If you are interested, please check the site called Docker Hub.
    In particular, all the famous images that are officially distributed include the Dockerfile used at the time of the build,
    It is written in the form ofFROM distribution nameon the top line of the Dockerfile.

    On the other hand, do not use an image that does not disclose the Dockerfile.

  • Answer # 2

    Ubuntu and CentOS have the same kernel but different commands.
    So, the Ubuntu and CentOS images have been reconfigured just like the command set, using the Linux kernel of the running environment as it is.

      

    Non-OS image (e.g. python)

    also actually runs on the Linux operating environment.

    Since neither MacOS nor Windows is Linux, dedicated Linux is prepared in a virtual environment.

  • Answer # 3

    Docker is a tool that relies on the Linux kernel, so it can't bedirectlyrun on macOS.

    When running Docker on macOS, a Linux virtual machine is started up and run in it.

    And distributions may vary from container to container, but the container kernel is always the Linux kernel.