I've recently started learning about containers, but I'm having a tough time wrapping my head around some concepts. I've got a couple of questions regarding Docker:
First off, the book I'm reading explains how to create a Docker image based on Debian with Nginx installed. I get that, but how is that different from a Debian virtual machine? At my workplace, we use virtual machines, and each one is dedicated to a specific application. So, what advantages do containers offer?
Secondly, I've pulled an Nginx image from Docker Hub, which is great, but Nginx needs to be configured. How do I access the configuration files without having a Debian shell? Also, how do I assign an IP to access the index.html from another PC on my network? Simply redirecting ports from the host doesn't seem sufficient. And if I create an image like a LAMP stack, how do I configure PHP?
I know these questions might seem basic, but I feel like I'm missing a key piece of understanding that would help me move forward. Any guidance would be appreciated, even if it comes with a bit of a reality check! Thanks!
1 Answer
A container is generally much smaller than a VM. It shares the same kernel as the host, which makes it more lightweight and simpler to manage. For your Nginx container, you usually mount a volume that contains your configuration files. Here's a quick command you could use:
```
docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d nginx
```
This way, you'd have your config linked in, making it easier to manage.

If you're going for a LAMP stack, you’ll need at least two containers—one for your PHP app and another for your database. Using Docker Compose is a good way to manage these setups. Happy coding!