rbz
rbz

Reputation: 769

Sharing installed tools from one container to all containers with docker compose

I am pretty new with Docker, and understanding how containers work and work together. I am creating a LEMP stack where i have nginx and php7-fpm as seperate containers. Each one has a Dockerfile and basically creates all i need. My issue though is when installing tools (such as ffmpeg, exiftool, etc..) in one container, is not available with the other container.

Is there any possible to have these tools available within all containers?

Upvotes: 0

Views: 154

Answers (1)

Jon Lasser
Jon Lasser

Reputation: 241

There's no straightforward way to ensure that tools installed in one already-defined container appear in other containers--that would be as though applications installed in one VM's filesystem appear in other VMs.

You could theoretically have one filesystem available to all of your containers, and put the tools in that one external filesystem, but if you think about it, that's not a great idea: all of a sudden, your container has an external dependency.

There are two approaches that could work here: First, if you're building your containers from scratch, you can add those tools to a common base image, and set your Dockerfile's From to use that base image instead of a basic OS image.

Second, if you're using third-party images for your containers, make new Dockerfiles, pointing the From to the third-party image, then installing the tools after the fact. Unfortunately, Dockerfiles don't support an INCLUDE statement, so either you need to copy the same instructions into all of your files separately or use a preprocessor to generate your Dockerfiles. (This is, to me, a good argument for a single shared base image.)

Upvotes: 1

Related Questions