Start Docker Container With Both Agent and Orion Server Running

Objective

Containerized environment where there are two containers up and running with the following objectives. Ideally the agent would be able to connect to Orion service so upon spinning up the work queue would be healthy.

Base work for this was taken from:
Base Service Link

 services:
  orion:
  # Runs Prefect Orion Server upon container spinning up
  prefect-agent:
  # Runs Prefect Agent upon container spinning up

Where I am

Right now I am struggling with working with the following docker-compose.yml file. The goal here is as stated above. The execution of docker compose up -d will spin up these containers successfully, but right now Prefect Orion Server will not start due to a binding issue on Port 4200, and the Agent does not seem to communicate with the server nor does it seem to start.

version: "3.5"

networks:
  prefect:
    name: prefect

  # --------------------------------------#
  #             Prefect Server            #
  # --------------------------------------#
services:
  ### Prefect Orion API
  orion:
    build:
      dockerfile: Dockerfile
    ports:
      - 4200:4200
    environemnt:
      PREFECT_ORION_API_HOST: 0.0.0.0
      PREFECT_API_URL: http://127.0.0.1:4200/api
    volumes:
      - /Users/wright.hilsman/Documents/projects/lennar/Athenix-Prefect/flows/:/opt/prefect/flows/
    networks:
      - prefect
  # --------------------------------------#
  #             Docker Agent              #
  # --------------------------------------#
  prefect-agent:
    image: prefecthq/prefect:2-python3.7
    command:
      - prefect
      - agent
      - start
      - -q
      - default
    depends_on:
      orion:
        condition: service_started
    environment:
      PREFECT_API_URL: http://127.0.0.1:4200/api
      PREFECT_LOGGING_LEVEL: DEBUG
      DOCKER_HOST: unix://var/run/docker.sock
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - prefect

My Dockerfile looks like the following from the Prefect Server portion.

FROM prefecthq/prefect:2-python3.7

ENV PREFECT_ORION_API_HOST=0.0.0.0

RUN mkdir -pv \
             /opt/prefect/flows 

COPY config config
COPY startup.sh /opt/prefect/startup.sh
RUN pip install -r /opt/prefect/config/requirements.txt
RUN ["chmod", "+x" ,"/opt/prefect/startup.sh"]


CMD ["/bin/bash","-c","/opt/prefect/startup.sh"]

Issue

  • Prefect Orion Start doesn’t seem to work on the Orion service now due to a port binding error
  • The times I’ve been able to get Orion Server up and running the Orion Service doesn’t communicate with the Agent service

check out this setup:

https://discourse.prefect.io/t/running-prefect-2-with-docker-compose/1516

and this post:

1 Like