0

I have a simple docker file that runs a bash script. The bash script makes a new Results directory. The output of my script is deposited there. Logically, the Docker container exits when it finalizes running, and the outputs are not automatically moved to the host machine. Is there a sort of "reverse COPY" that will deposit the Results directory in my host directory? I plan to integrate the Dockerfile into a WDL, so I cannot get the container_id to use docker cp as described here.

FROM condaforge/mambaforge:22.9.0-1

COPY master.sh .
ENTRYPOINT ["/master.sh"]

And master looks like this

#!/bin/bash

mkdir Results
cat Data/data.txt > Results/results.txt

And the commands to build and run the docker container are:

docker build --platform linux/amd64 -t test:Dockerfile .
docker run -v /Path/To/Data:/Data --platform linux/amd64 -it test:Dockerfile bash
Cyrus
  • 84,225
  • 14
  • 89
  • 153
je2018
  • 125
  • 5
  • Assuming `WORKDIR` is `/`, you're example already saves to the host filesystem via the volume mount `-v /Path/To/Data:/Data`. – jordanm Jul 04 '23 at 04:18
  • 1
    I am confused by the title and the content of the question. A "reverse copy" would mean copying from the image during build to the local machine, which is the total opposite of what the dockerfile is supposed to do: build the image. – Itération 122442 Jul 04 '23 at 07:07
  • I've linked this to the canonical questions on copying files out of images and containers. As @jordanm notes, the `docker run -v` volume mount should be enough (you may also need to mount a `/Results` directory). If you're just trying to run a shell script, consider whether you could do it on the host without involving Docker at all. – David Maze Jul 04 '23 at 10:53

0 Answers0