I was just wondering how to run a docker-entrypoint script in another directory. For example,
the-service:
image: the-service
container_name: the-service
entrypoint: ./app/the/docker-entrypoint.sh
build: ./app/the
ports:
- 8080:8080
here I get
ERROR: for the-service Cannot start service the-service: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"./app/the-service/docker-entrypoint.sh\": stat ./app/the-service/docker-entrypoint.sh: no such file or directory": unknown
ERROR: Encountered errors while bringing up the project.
docker-compose version is 2.1. So what is the correct way of running this script?
Thanks
I think I have figured it out. You are using the build option so that the docker image can live inside the docker-compose project. This is a little non-standard, but perfectly OK. Using image is more standard.
The entrypoint is executed after the build, regardless of the position in the docker-compose.yml file. When we write the entrypoint, we are writing a reference to a file in the image not the local file system.
You should probably edit your .app/the/Dockerfile as follows add "COPY docker-entrypoint.sh /" add "ENTRYPOINT ["sh", "/docker-entrypoint.sh"]
Then you can edit your docker-compose.yml by removing the "entrypoint: ./app/the/docker-entrypoint.sh"
OLD ANSWER
Without testing it out myself, I would assume that these would work:
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