Setup
I have a Physical Machine (PM) running on Debian GNU/Linux 11 (bullseye) and a remote Virtual Machine (VM) running on AlmaLinux 8.7 (Stone Smilodon) on the same network.
Goal
I would like to run a container with a Prefect server on the VM and to access the Prefect UI from anywhere on the network by requesting http://<VM_ip>:4200
.
This would allow for a local development of the new Flows and then a simple way to run them. (For anyone who may have used the docker-compose.yaml
from Airflow, I would like to reproduce this behavior)
Issue
On my PM, I can run Prefect either directly (prefect orion start
), or in a container (docker run --network host -it prefecthq/prefect:2-latest prefect orion start
). In these cases, I can see the relevant Flows’ executions, etc.
The problem arises when I try to relocate my Prefect server onto my VM.
It seems whatever I tries, I ultimately end up with a Can't connect to Orion API at http://0.0.0.0:4200/api. Check that it's accessible from your machine.
error message when trying to open the Prefect UI on my PM. Other than this, Prefect seems to be running correctly in the container (i.e I can build
, apply
and run
Flow deployments)
What have I tried
The main thing I have tried is the following command:
docker run
--name prefect
--env PREFECT_ORION_API_HOST=0.0.0.0
-v ~/containers/prefect/deployments:/deployments
-p 4200:4200
-d prefecthq/prefect:2-latest
prefect orion start
As far as I understood it, it should have done the same as the container deployment on the PM, while exposing the port 4200
to authorize access from outside.
Where I have looked
I tried asking my question on the Prefect Discourse but, while I have received answers, none of them seem to have done the trick. Among the answers was looking into the Prefect Docker compose method, but this also fails in the same fashion.
Where is the error here? Is it at all possible? Thanks for reading, commenting and answering!
2
Answers
You could do:
The issue here is that orion is sending requests directly to your local machine in terms of API requests, as opposed to routing them through the backend server to the API server that is also running on your VM as a part of Orion. In my opinion, this is not a sane default, but that’s how it’s currently implemented.
To solve, you need to supply the public ip address of your virtual machine as
PREFECT_ORION_API_HOST
.