skip to Main Content

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

2

Answers


  1. 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.

    Login or Signup to reply.
  2. 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/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search