From everything I've read and heard about Docker, the whole point of it is to encapsulate an application so that it is runnable on any machine. It achieves this by wrapping up the environment needed (tools/dependencies) into the docker image. A container is an instance of an image. There isn't an OS running in a docker container.
Now, if that's all true, then why does this exist: CentOS official docker image? I thought docker images were just for applications, not entire operating systems.
Whenever I instantiate that image, I get a container that, when attached to it, appears to be a functioning CentOS shell.
You can do it yourself to see what I mean:
- Dockerfile contents:
FROM centos:centos7
- Build the image:
docker build centos-img .
- Run the container:
docker run -ti centos-img
- To detach:
ctrl+p, ctrl+q
- To reattach:
docker attach <container id>
This really looks and feels like a VM.
If I run cat /etc/os-release
it even says I am running CentOS.
What exactly is this? Could I use a CentOS docker image as if it were a virtual machine? What are the limitations?
(What's confusing me is docker containers != VMs
, however, from by exploration, I created a docker image that looks and feels like a VM. Why would I ever want to run a VM again, if I can run a lightweight docker image that acts exactly like a VM?)
Is this centOS docker image just a starting place, that I am supposed to build off of (ie, put my application in), so that it just functions as a host for my application? The more I read and dig into Dockerfile examples, the more I believe this is assumption is true.
What I'm really trying to do:
I have a bunch of small applications/services that function together as a system that make up a large application. I currently have this system running on a centOS machine. I want the ability to easily run multiple instances of this large application, each in their own environment / without stepping on each other's toes. Would it be possible to do this by using a centOS docker image + all of the small applications/services needed
, resulting in a large application image
? With this image, I can spin up multiple containers, each one running a separate instance of the large application? Is that a reasonable/achievable thing to do with Docker?
Some of my understanding may be incorrect, or I may be suggesting to use Docker in a way that it is not meant to be used. If so, feel free to point it out. Thanks!