In my application, I have 5 docker containers and each container starts from images that builds from Dockerfile. Following is the structure:
-projectdir
-docker
-application1
-Dockerfile
-script.sh
-application2
-Dockerfile
-script.sh
-application3
-Dockerfile
-application4
-Dockerfile
-script.sh
-application5
-Dockerfile
script.sh is copied in the Dockerfile in application 1,2&4. The problem is I have to put the same script.sh in each application directory. Is there any way to use shared folder that contain single script.sh and copy from that? I am using docker-compose to build and run the containers.
You could define a container dedicated to keep your script in a volume (as a data volume container)
scripts:
volumes:
- /path/to/scripts
application1:
volumes_from:
- scripts
application2:
volumes_from:
- scripts
The /path/to/scripts
folder will be shared in each application.
The scripts
Dockerfile should create /path/to/scripts
and COPY the script.sh
in it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With