I just started using docker a couple of weeks ago and intend to use it to run some PHP sites on apache and ubuntu in Amazon ECS. My question is about the use of FROM in specifying images and layering dependencies.
Originally I’d planned to create an image apache2-php5 (FROM ubuntu) with all of those components and required apache modules enabled, then create an image mysite1 (from apache2-php5) with just my site code and each additional site the same way - mysite2 (from apache2-php5).
After looking at docker-compose; however, and seeing how ECS handles this with multiple containers specified for a single task, I’m now confused b/c (using docker-compose as the example) I can specify other images as requirements for the site image in the docker-compose.yml file and then link the containers.
So now I’m confused about the best way to handle this layering of containers to maximize efficiency, maintenance, portability, and resource utilization.
Based on my current understanding I see 3 options:
- Use my originally invisioned method for building the site images, and when I deploy I only need to deploy a container for mysite1 because it will automatically pull down the other images needed.
- The image for mysite1 will instead be built FROM the base ubuntu image and when I deploy I will have to state that it requires the apache2-php5 image as well and perhaps link the two containers (?)
- I create an image for mysite1 from ubuntu and have all the build for apache, php, etc… performed explicitly in this container in its entirety. This seems less efficient to me if i’m deploying multiple sites with the same underlying apache requirements, but maybe I’m missing something about how that works.
Thanks a ton in advance. I’ve been racking my brains over this one.