Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy files to docker image after build

I do have an already build docker image and wan't to add files to it AFTER the build was done. Is there a way to add files without rebuilding it (or maybe to add it and save it with an new tag)? I did find docker cp but if I understand that right it does only work in running containers.

like image 452
MTRNord Avatar asked Oct 07 '16 11:10

MTRNord


People also ask

Can you copy a file into a Docker image?

You can use the docker cp command to copy the file. The first path (Source) is the path in the Docker Container and the second one is the path inside your Local System (Destination).

How do I copy a file in Docker?

Obtain the name or id of the Docker container. Issue the docker cp command and reference the container name or id. The first parameter of the docker copy command is the path to the file inside the container. The second parameter of the docker copy command is the location to save the file on the host.

Which Dockerfile command defines files to copy from the host file system onto the container?

Docker cp Command It can only be used to copy files between the host system and a single container.


Video Answer


1 Answers

docker cp but if I understand that right it does only work in running containers

Still, that might work considering you can then commit a container into a new image.
See docker commit.

docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
like image 50
VonC Avatar answered Sep 22 '22 14:09

VonC