Home > front end >  Copy a file in container on docker run
Copy a file in container on docker run

Time:08-19

I have a container, and i have a json file where is some information to start my api.
The problem is that i need to deploy mutiple container with different json file
So here is my question as we do the COPY in dockerfile is there a way to copy a file into the container on the docker run.

The use of secret is not possible because my client doesn't want to use swarm.

Thanks for reading

CodePudding user response:

You could use the existing image as a base image, and add a new Dockerfile with the single COPY step. Then docker build would add the new file.

Alternatively -- and this is how secrets and configmaps are implemented anyway -- mount the file/folder with the --mount argument with docker run.

CodePudding user response:

Yes.

After you have your container running with docker run

Do a docker ps to get the docker container id or name and

docker cp local file containerid:/remote path

https://docs.docker.com/engine/reference/commandline/cp/

  • Related