0

I wish to have certain scripts present in the host machine to be present inside the docker container when the container is created. How to I ensure this ? Thanks

akrish
  • 1
  • 2

3 Answers3

0

You can use a COPY or an ADD statement in your Dockerfile.

COPY <src> <dest>

Docker will error when the file isn't present on the host.

See also:

Community
  • 1
  • 1
svdb
  • 36
  • 4
0

Create a customized image for your container, use COPY or ADD statement in that image's Dockerfile to add scripts to customized image. Once you have the image, use it to start container then this container will have scripts you added.

Haoming Zhang
  • 2,672
  • 2
  • 28
  • 32
0

If you can't, for any reasons, add the scripts to the image at creation with COPY or ADD, the only solution imho would be to mount the folder on the host machine into the container at runtime with the -voption. But in this case you will still need a kind of mechanism build in the image to trigger the script to execute. Via cron or something similar. Maybe have a look at the Phusion Baseimage as it has cron build in and an option to run scripts at container runtime, see here

kgorskowski
  • 745
  • 5
  • 12