user6152171
user6152171

Reputation:

Changing the image in Docker Compose based on the host OS

I am creating a PHP app, and using Docker + Docker Compose to run it.

My problem is, I want users to be able to run my project on any OS with no hassle. However, the official mysql:latest image is not supported on ARM processors (such as the Raspberry Pi), and so has to be switched out to hypriot/rpi-mysql.

Is it possible to do this either within one Compose file or with separate files for each platform? Or will users have to manually swap in a YML file when they clone the project?

Upvotes: 6

Views: 2633

Answers (1)

grapes
grapes

Reputation: 8646

You can split your project into several YAML files, putting OS-independent stuff into one and dependent - into others. Your files will look like:

docker-compose.yml       -- common stuff lives here
docker-compose-x64.yml   -- lots of OS-dependent services for x64
docker-compose-arm.yml   -- lots of OS-dependent services for arm

Then you just need to launch this in following manner:

# for x64
docker-compose -f docker-compose.yml -f docker-compose-x64.yml up ...
# for arm
docker-compose -f docker-compose.yml -f docker-compose-arm.yml up ...

Upvotes: 3

Related Questions