snippetdockerMinor
How can I load multiple paths into the workspace during docker run?
Viewed 0 times
canthehowduringintodockerpathsmultipleloadworkspace
Problem
My datasets and codes are in different folders and they don't have immediate parent folder.
I want my codes to access my datasets while using docker run. Is there a way to load both codes and datasets folder into workspace?
I want my codes to access my datasets while using docker run. Is there a way to load both codes and datasets folder into workspace?
Solution
You can use Docker volume mounts at run time. For example:
This mounts two directories on the host into the docker container. Notice in this example that inside the container, they are mount on inside the other.
$ mkdir -p app/src logs
$ touch app/src/foo.c logs/bar.txt
$ docker run --rm -v $PWD/app:/app -v $PWD/logs:/app/logs alpine ls -l /app /app/src /app/logs
/app:
total 8
drwxr-xr-x 2 1000 1000 4096 May 6 23:33 logs
drwxr-xr-x 2 1000 1000 4096 May 6 23:33 src
/app/logs:
total 0
-rw-r--r-- 1 1000 1000 0 May 6 23:33 bar.txt
/app/src:
total 0
-rw-r--r-- 1 1000 1000 0 May 6 23:33 foo.cThis mounts two directories on the host into the docker container. Notice in this example that inside the container, they are mount on inside the other.
Code Snippets
$ mkdir -p app/src logs
$ touch app/src/foo.c logs/bar.txt
$ docker run --rm -v $PWD/app:/app -v $PWD/logs:/app/logs alpine ls -l /app /app/src /app/logs
/app:
total 8
drwxr-xr-x 2 1000 1000 4096 May 6 23:33 logs
drwxr-xr-x 2 1000 1000 4096 May 6 23:33 src
/app/logs:
total 0
-rw-r--r-- 1 1000 1000 0 May 6 23:33 bar.txt
/app/src:
total 0
-rw-r--r-- 1 1000 1000 0 May 6 23:33 foo.cContext
StackExchange DevOps Q#11539, answer score: 3
Revisions (0)
No revisions yet.