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
3 Answers
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:
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.

- 2,672
- 2
- 28
- 32
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 -v
option. 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

- 745
- 5
- 12