cluis92
cluis92

Reputation: 932

How to Add a shared folder location to my application (Docker)

I have a shared network folder, e.g.

\\pa02ptsdfs002.corp.lgd.afk\files\Public\chris\temp

There is a file in the shared folder that I would like to be visible to my dockerized application. The ultimate goal is, to have my application pick up and process this file, then put it into a database.

I have a Dockerfile and docker-compose.yml that I am thinking I will need to add a volume with the shared folder location (I'm not sure if this is the correct approach, this is where I need help!)

So far I've tried adding a volume in my yml which threw an error when i did docker-compose up -d

    airflow:
        build: ./airflow
        image: digitalImage/airflow
        container_name: di-airflow
        environment:
            AIRFLOW__CORE__EXECUTOR: 'LocalExecutor'
            POSTGRES_USER: 'airflowStuff'
            POSTGRES_PASSWORD: 'postgresCreds'
            POSTGRES_HOST: 'host-postgres'
            POSTGRES_PORT: '5432'
            POSTGRES_DB: 'postgres-db'
            DATE_VALUE: '1 DEC 2020 00:00:00'
        volumes:
            - ./airflow/released_dags:/usr/local/airflow/dags
            - \\pa02ptsdfs002.corp.lgd.afk\files\Public\chris\temp:/usr/local/airflow/dags/inboundFiles
        networks:
            - di-airflowStuff
        ports:
            - 8081:8080
        depends_on:
            - postgres

ERROR: Cannot create container for service airflow: \pa02ptsdfs002.corp.lgd.afk\files\Public\chris\temp%! (EXTRA string=is not a valid Windows path)

p.s. I can access this shared folder location from my file explorer and python without a problem.

Upvotes: 1

Views: 2122

Answers (2)

Iñigo González
Iñigo González

Reputation: 3955

Microsoft recomends mapping shares to network drives (if you're running docker on Windows):

https://learn.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/persistent-storage#smb-mounts

Upvotes: 1

Petronella
Petronella

Reputation: 2545

You don't need docker-compose to mount an external volume to your container, just configure it when running the container:

docker run --name name -v path_host:path_in_container image:tag

both directories must exist

Upvotes: 1

Related Questions