eolas/zk/Docker_Compose_entrypoint.md

31 lines
724 B
Markdown
Raw Permalink Normal View History

2026-01-08 19:45:38 +00:00
---
tags:
- docker
---
The `entrypoint` key in a Docker compose file is useful for running any advanced
scripts before the the main `cmd` is executed.
```sh
app:
image: python:3.11-slim
entrypoint: ["./entrypoint.sh"]
command: ["python", "src/app.py"]
```
I used it recently to inject a `.pem` certificate into the container before the
main execution.
The script must conclude with `exec "$@"` because it receives the value of the
`command` key in the Compose file as its argument. E.g.
```sh
cat /etc/ssl/certs/ca-certificates.crt /zscaler.pem > /tmp/combined-certs.pem
export REQUESTS_CA_BUNDLE=/tmp/combined-certs.pem
export SSL_CERT_FILE=/tmp/combined-certs.pem
pip install -r requirements.txt
exec "$@"
```