In this blog post, we will learn how to copy files or folders from the container host to a running Linux container.
Copy files to a running can be handy sometimes and prevent downtime when there is a need to test a new configuration.
For this purpose, the Docker CLI gives us the option to copy files and folders from our container host file systems directly into the container’s file system without any disruption.
In the following example, I will do the following. Create a Linux container with Ubuntu. Copy a single file called readme.md to the container’s /etc. folder.
docker run --name deploy01 -ti -d ubuntu:latest /bin/bash docker container cp readme.md deploy01:/etc
To check that the file was copied to the container, I will use the attach command to log in to the container.
docker container attach deploy01
To view the etc. folder I will run.
Leave a Reply