I’m trying to set some resource limits into a docker container. I’m able to add the below values to a docker-compose.yml file for docker resource limits;
resources:
limits:
cpus: '2'
memory: 4GB
reservations:
cpus: '1'
memory: 4GB
How would I pass them in via gitlab pipeline for the container being built but set them as variables?
I was able to override the java heap size by adding;
java_xmx=${JAVA_XMX_OVERRIDE}
and the value
JAVA_XMX_OVERRIDE: "-Xmx2048m"
How would I do the same with resource limits?
Thanks
2
Answers
I've ended up adding a docker-compose file template in the pipeline, in the template I modified the resource limits with ansible
You can use variables in docker compose which you can propagate with the starting command.
compose.yaml:
Start container:
You should be able to define an environment variable in your gitlab pipeline: