In cases where you're using environment variables to configure the instance, you should ensure these environment variables are exposed in the container running Dagit.
Dagit servers expose a health check endpoint at /dagit_info, which returns a JSON response like:
More advanced Dagster deployments will require deploying more than one container. For example, if you are using the Dagster daemon to run schedules and sensors or manage a queue of runs, you'll likely want a separate container running the dagster-daemon service.
This service must have access to your dagster.yaml and workspace.yaml files, just like the Dagit container. You can also configure your code location server (gRPC server) so that your code can be updated and deployed separately in its own container, without needing to redeploy the other Dagster services. To enable this setup, include a container exposing a gRPC server at a port and add that port in your workspace.yaml file.
For example, your user code container might have the following Dockerfile:
FROM python:3.7-slim# Checkout and install dagster libraries needed to run the gRPC server# exposing your repository to dagit and dagster-daemon, and to load# the DagsterInstanceRUN pip install \
dagster \
dagster-postgres \
dagster-docker# Set $DAGSTER_HOME and copy dagster instance thereENV DAGSTER_HOME=/opt/dagster/dagster_homeRUN mkdir -p $DAGSTER_HOMECOPY dagster.yaml $DAGSTER_HOME# Add repository codeWORKDIR /opt/dagster/appCOPY repo.py /opt/dagster/app# Run dagster gRPC server on port 4000EXPOSE 4000# Using CMD rather than ENTRYPOINT allows the command to be overridden in# run launchers or executors to run other commands using this imageCMD ["dagster", "api", "grpc", "-h", "0.0.0.0", "-p", "4000", "-f", "repo.py"]
And your code location server might look like:
load_from:# Each entry here corresponds to a container that exposes a gRPC server.-grpc_server:host: docker_example_user_code
port:4000location_name:"example_user_code"
When you update your code, you can rebuild and restart your user code container without needing to redeploy other parts of the system. Dagit will automatically notice that a new server has been redeployed and prompt you to refresh.
When you add or remove a user code container, you can also remove the corresponding entry from your workspace.yaml file. If this file is mounted on the Dagit and Dagster daemon containers as a volume, you can pick up the changes in Dagit by reloading from the Deployment tab. The Dagster daemon container will automatically pick up the changes by periodically reloading the workspace.yaml file.
This launcher will start each run in a new container, using whatever image set in the DAGSTER_CURRENT_IMAGE environment variable in your user code container. This will usually be the same image as the user code container itself.
Any container that launches runs - usually the dagster-daemon container if you're maintaining a run queue or launching runs from schedules or sensors - must have permissions to create Docker containers in order to use this run launcher. Mounting /var/run/docker.sock as a volume is one way to give it these permissions.
You can mount your code in your user code container so that you don't have to rebuild your container whenever your code changes. Even if you're using volume mounts, you still need to restart the container whenever your code changes.
If you're mounting your code as a volume in your user code container and using DockerRunLauncher to launch each run in a new container, you must specify your volume mounts in the DockerRunLauncher config as well. For example: