I want to clear up some ambiguity in my head. I am running a baremetal server with CentOS7 on a local business network behind NAT. Because the main software on CentOS7 requires PHP 5.4.16 and cannot be upgraded I have to work around what I want to achieve which is to install multiple softwares on either a Virtual Machine(VM) or Docker Container/Image/Repository with their own ip address and dns for their domain. Challenge is I am not sure which one to work with. Let's say this scenario will have an ∞ amount of users, so my hardware will be the bottleneck.

To my understanding a VM is like its own "entity" mutually exclusive from the CentOS7 OS I am currently running on, but still running off the hardware of the CentOS7 server.

I can install multiple softwares on this VM and it will auto boot up upon CentOS7 restart saving ip and dns configurations.

Now a Docker container is stateless, meaning if I reboot my server the Container/Image/Repository will lose all software installs and ip address / dns configuration. However, this doesn't sound accurate. I feel like I can achieve the same result with the VM or Docker


Docker containers will remember their configuration. So whatever you setup should come back up when you restart it with docker start or it automatically restarts. Networking config is done when you initially create a container with docker run. So there's still some risk of trashing your container and losing it's config.

A better option is to use docker-compose to define exactly what you want to run (including networking). That way if you do destroy your container you can always spin up a new one with identical configuration.

Docker really shouldn't be thought of as a VM though. Containers are designed to wrap up single services not entire machines.

If you just need to run something with PHP 5.4.16 then you can easily run PHP inside a docker container with something like php-fpm (docker pull php:fpm) and then serve this with either nginx or apache.

You can mix and match between running processes in containers and natively on the host if you need to.


No the difference between VM and container is not state.

Yes Docker can forget some state, not configuration. But will normally forget changes make to the file-system, when it is re-started. However it can be configured not to do this. However you probably don't want to do this.

The main difference is that a VM virtualises the hardware. You have to run a full OS on it. A container runs on the hosts kernel. It is a way to run processes in a namespace (an isolated environment). Namespaces are a part of the Linux kernel. Docker uses features of the kernel that any sufficiently privileged process could use.

Sometimes you can do both containers and VMs. This is what docker for MS-Windows does when you run a Linux container.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.