Hi team, trying to mount my local code as a volume...
# ask-community
a
Hi team, trying to mount my local code as a volume in DockerRunLauncher as mentioned here, but not able to make it work. However, the volume mount works for user code repository from docker-compose. Am I missing something here? I am on
0.12.12
Copy code
run_launcher:
  module: dagster_docker
  class: DockerRunLauncher
  config:
    env_vars:
      - DAGSTER_POSTGRES_USER
      - DAGSTER_POSTGRES_PASSWORD
      - DAGSTER_POSTGRES_DB
    container_kwargs:
      volumes:
        - etl:/home/app/etl
    network: dagster
Looks like the volume is being cached somehow and it does not reflect my local changes
j
If you
docker inspect
does it show the volume mount?
I would go through some of the debugging at https://docs.docker.com/storage/volumes/
a
I went through the docs, but I am not sure how to specify the mount in the `dagster.yam`l for the DockerRunLauncher. FYI, here is how I mount the volume in the
docker-compose.yml
for the user-code eposiotry.
Copy code
metrics_repo:
    build:
      context: ../
      dockerfile: local_dev/Dockerfile_metrics_repo
      args:
        - PIP_EXTRA_INDEX_URL
    container_name: metrics_repo
    image: metrics_repo_image
    restart: always
    expose:
      - "9090"
    ports:
      - "9098:9090"
    environment:...
    volumes:
      - "../etl:/home/app/etl"
    networks:
      - dagster
d
Arun what are you doing to check/verify whether the volume is set? How is the failure appearing?
j
I am not sure how to specify the mount in the
dagster.yaml
for the DockerRunLauncher
You were on the right track with
Copy code
run_launcher:
  module: dagster_docker
  class: DockerRunLauncher
  config:
    env_vars:
      - DAGSTER_POSTGRES_USER
      - DAGSTER_POSTGRES_PASSWORD
      - DAGSTER_POSTGRES_DB
    container_kwargs:
      volumes:
        - etl:/home/app/etl
    network: dagster
If you take a look at https://docs.docker.com/storage/volumes/#choose-the--v-or---mount-flag, it would be mounting the volume named
etl
at
/home/app/etl
a
@daniel As Johan mentioned previously, I inspect the docker volume and also try running a job run to validate
d
Just to sanity check - if you go to /instance/config in Dagit, you see the run launcher config there the way you expect, with the volume set?
a
@johann With that approach, how can I specify the destination directory? The below config config works for me where I specify my local folder as source and container directory for destination. Now I want to understand how I can make the source directory more generic rather than specifying the exact absolute directory to my local code
Copy code
run_launcher:
  module: dagster_docker
  class: DockerRunLauncher
  config:
    env_vars:
      - DAGSTER_POSTGRES_USER
      - DAGSTER_POSTGRES_PASSWORD
      - DAGSTER_POSTGRES_DB
      - SNOWFLAKE_USERNAME
      - SNOWFLAKE_PASSWORD
    container_kwargs:
      volumes:
        - /Users/arunkumar/Projects/metrics-repo/etl:/home/app/etl
    network: dagster
@daniel yes, I see it with the above config
d
oh, great - so it's working in general, the question is how to make it work with a relative path rather than an absolute one
2
a
Yes right. Sorry for not making it clear
d
everything I can find online suggests prepending it with the $CWD env var which isn't really an option in dagster.yaml - you may need to add an additional step that creates the dagster.yaml file from a template and subs in the value of $CWD 😕
a
I found the same. Could you tell me more about additional step? Not sure if I understand that
d
I was imagining using something like jinja to template in the final dagster.yaml file using environment variables
a
Ah got it, will give that try. Thanks for the help Daniel.