Home > Blockchain >  How to rename a file in docker image during docker run command?
How to rename a file in docker image during docker run command?

Time:01-24

I want to rename a conf.dev.json file to conf.json within the image during docker run time. How is this accomplished?

I don't want to rename the file during image build because I don't want to build env specific images and mounting a volume wont really work because I'm serving the file from within nginx server running in the container which is serving the site from the container image's /html directory.

CodePudding user response:

ok it looks like with nginx there is a magic folder that contains scripts to execute when the images starts.

https://stackoverflow.com/a/70575191/491436

I'm going to try this but if there is a more elegant way to approach this please do let me know.

Thanks!

CodePudding user response:

If the file config.dev.json is located in /local on your host and the target file inside the container should be located in /tmp/config.json, then

docker run -v /local/config.dev.json:/tmp/config.json -it -p 8080:8080 yourimage
  • Related