Copy files to/from host to docker container
For example you have an apache tomcat container and you want to save the access log to your local host.
This what you do:
#start the container
docker run -d -p 8080:8080 --name tomcat9 tomcat:9-alpine
#copy the access log to the hosts current directory
docker cp tomcat9:/usr/local/tomcat/logs/localhost_access_log.2017-09-07.txt .
Where /usr/local/tomcat/logs/localhost_access_log.2017-09-07.txt is the location of the file to copyand . is your local folder.
Adding a file to the container is similalry simple:
docker cp myhostscript.sh tomcat9:/usr/local/tomcat/bin/.
This will add the file myhostscript.sh to the running container's /usr/local/tomcat/bin folder.
Reference:
Docker documentation on cp
Comments
Post a Comment