0

I have the following docker-compose.yml file where I have a service that does:

  service:
    container_name: service-name
    image: service-image
    command: >
      /bin/bash -c "
        command1;
        command2;
        command3
        "

This docker-compose.yml works fine. The problem is that the script of the "command" is becoming complex and I want to externilize it in configure.sh script so that in my folder I have:

docker-compose.yml
configure.sh

is there a way to call configure.sh from the "command" option? The image service-image comes from Docker-HUB and there is not a chance I can copy configure.sh into the image unless I extend it with my own image. However, I would like to avoid this.

Salvatore D'angelo
  • 1,019
  • 3
  • 14
  • 39
  • https://stackoverflow.com/a/42260979/94746 – snahor Feb 17 '21 at 17:24
  • Does this answer your question? [How to mount a single file in a volume](https://stackoverflow.com/questions/42248198/how-to-mount-a-single-file-in-a-volume) – snahor Feb 17 '21 at 17:25
  • thank you snahor, the solution was really easy. I don't know how I didn't think about it. However, there is a problem. The commands use some environment variables that only docker-compose.yml knows their value. How I can transfer these values to the scripts when it run inside the container? Take into consideration that the container is not aware of this env variables. – Salvatore D'angelo Feb 18 '21 at 09:01
  • Probably, I found a solution. I have a .env file with these variables. I can mount also this file and do "source .env" in my main script. – Salvatore D'angelo Feb 18 '21 at 09:07

0 Answers0