Docker Community Forums

Share and learn in the Docker community.

Docker-compose: How to make Airflow container able to run commands in another container?


(Chrisbeach) #1

I have a legacy PHP web-app which I’d like to modernise via docker-compose.

The app formerly used cron to run schedule commands, and I’d like to substitute Apache Airflow for this.

So, I have a docker-compose file that looks like this (simplified):

services:
   php:
     build: .
     container_name: web
     ports:
       - '8080:80'
     ...
   airflow:
     image: puckel/docker-airflow:1.10.0-2
     ports:
       - "8081:8080"
     command: webserver
     ...

I’d like Airflow to be able to run commands in the PHP container. Two reasons for doing it this way:

  • I’m struggling to create an image based on Airflow which installs PHP and my app dependencies. Can’t sudo in a Docker image that is based on puckel/docker-airflow:1.10.0-2
  • I’d like to avoid setting up a mirror of my app and its dependencies within the Airflow image

What’s the best way of doing this? Would it be to ssh from the airflow container to the php container. Could someone advise on what I’d need to do to enable this?