Open nateGeorge opened 4 years ago
i have this same question
I'm having the same issue, to be more specific:
Commands like these work great:
> docker-compose -f docker-compose-CeleryExecutor.yml run --rm webserver airflow list_dags
> docker-compose -f docker-compose-CeleryExecutor.yml run --rm webserver airflow connections --list
But if we exec
the docker container, and run the same commands, it will throw an error:
> docker exec -it <container ID from 'docker ps'> /bin/bash
> airflow connections --list
The same error will happen if we exec
after running docker-compose -f docker-compose-CeleryExecutor.yml up -d
An interesting thing happens if we run the following commands after the docker exec
above:
> airflow upgradedb # or 'airflow initdb'
> airflow connections --list
In this scenario we don't get any error, but the DB used is no longer the same...
So it seems as if the connection to the PostgresDB is lost after running docker exec
, no idea why...
Did anyone fix this?
So the solution was suggested at this Slack thread: https://apache-airflow.slack.com/archives/CCQ7EGB1P/p1585679850223300
After running docker-compose
we need to run:
> docker exec -it <container id> /entrypoint.sh bash
And all commands will work
Thanks to Jed Cunningham for the solution
The workaround @dvainrub mentioned solved my problem.
Is it possible to run airflow CLI commands using docker-compose without reinstalling requirements.txt? Right now to run the airflow CLI it's:
docker-compose -f docker-compose-CeleryExecutor.yml run --rm webserver airflow list_dags
but this will reinstall from the requirements.txt file as it spins up a new container. Is there some way to run airflow CLI commands with exec? When I do:
docker-compose -f docker-compose-CeleryExecutor.yml run --rm webserver airflow list_dags
I get the error:
But it works fine with
run
. I'm pretty confused as to why exec won't work and run does. Is it possible to run airflow CLI commands withexec
?