Running docker on the host command line, I can run a command in a container that downloads a set of files, and shares those files back to host via a shared volume:
docker run --rm --volume "${PWD}":/contentmine --tty --interactive psychemedia/contentmine getpapers -q aardvark -o /contentmine/aardvark -x
What I would like to do is to be able to run the same command from within a Jupyter container created using a docker-compose.yaml file of the form:
notebook:
image: jupyter/notebook
ports:
- "8899:8888"
volumes:
- ./notebooks:/notebooks
- /var/run/docker.sock:/var/run/docker.sock
privileged: true
In a Jupyter notebook code cell, I tried running:
#Make sure docker is available in the Jupyter container
!apt-get update
!apt-get install -y docker.io
!mkdir -p downloads
#Run a download command in another container and share the downloaded files back
! docker run --rm --volume "${PWD}/downloads":/contentmine --tty --interactive psychemedia/contentmine getpapers -q aardvark -o /contentmine/aardvark -x
I can see the files are downloaded somewhere, but I don't know where? Are they downloaded into the docker VM context outside the Jupyter container? How can I mount a directory from my notebook container within the temporary container I'm using to run the file downloading command-line container?
As a part 2 to the question, I'd then also want to be able to use the files in downloads
directory as an input to another command line command run in another container and again keep a copy of the results in the notebook container downloads
directory:
docker run --rm --volume "${PWD}/downloads":/contentmine --tty --interactive psychemedia/contentmine norma --project /contentmine/aardvark -i fulltext.xml -o scholarly.html --transform nlm2html
Presumably, if there's a quick fix to the first part of the question, the same fix applies to this part?