I am trying to create a docker-compose for a project that requires a service to be running in the background. The image for service exists and this contains a config file, as well as an entrypoint ["/usr/bin/java", ...]
I would like to change the content of configuration file but I am not sure what would be the best way to do it without creating an extra dockerfile to just recreate image with appropriate files?
Since the entrypoint is /usr/bin/java , I am not sure how I would be able to use docker-compose's command to modify file content.
version: 2
services:
myService:
image: serviceA from registry
# Would like to modify a config file's content...
mainAPI:
...
Thank you
You need to add a volumes reference in your docker-compose.yml.
version: 2
services:
myService:
image: serviceA from registry
# Would like to modify a config file's content...
volumes:
- /path/to/host/config.conf:/path/to/container/config/to/overwrite/config.conf
mainAPI:
...
Since 3.3, you can also create your own docker config file to overwrite the existing one. This is similar to above, except the docker config is now a copy of the original instead of binding to the host config file.
version: 3.3
services:
myService:
image: serviceA from registry
# Would like to modify a config file's content...
configs:
- source: myconfigfile
target: /path/to/container/config/to/overwrite/config.conf
mainAPI:
...
configs:
myconfigfile:
file: ./hostconfigversion.conf
See https://docs.docker.com/compose/compose-file/#long-syntax for more info.
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