0

I am running a docker container on Jenkins. I can't install anything on jenkins, so I did some processing on docker and want to get the results out to the host. If I set an environment variable in the docker container, how do I extract it to my jenkins host?

I can see that I can write the env variable to a file and copy it to the host, but is there another way ?

Illusionist
  • 5,204
  • 11
  • 46
  • 76

1 Answers1

0

When running the container, you can mount a file or a folder into the container. Inside your container, you can write to this file and have the changed reflected on the host file on the machine.

To do that create a file result.txt on the host machine and when running the container, specify the -v option to mount the file.

docker run -v ./result.txt:/result.txt ...

And let the jenkins job write the results into this file.

yamenk
  • 46,736
  • 10
  • 93
  • 87