How to transfe files between Docker containers?

76 Views Asked by At

I have a docker-compose file that defines two services: Caddy and EMQX. Caddy is a web server that generates SSL certificates using Let's Encrypt, and EMQX is an MQTT broker that needs to use these certificates for the MQTTS protocol.

I want to share the certificates between the two containers, so I have created a volume named certs and mounted it to both the /data/caddy folder in the Caddy container and the /opt/emqx/etc/certs folder in the EMQX container.

However, I have encountered a problem with the file ownership. Caddy creates the certificates with the root owner, but EMQX runs as the emqx user. This causes the certificates in the EMQX container to be owned by root instead of emqx, which prevents EMQX from using them.

I know I can use the chown command to change the ownership manually, but I don't want to do that every time. Is there a way to automate this process, or a better way to share the certificates between the containers? I am looking for a solution that works with docker-compose. Thank you.

0

There are 0 best solutions below