There was a scene where I wanted to bring a file locally from a docker container. Make a note of what you have investigated there.
The procedure for actually copying httpd.conf, which is the configuration file of the httpd container, from the container to the local (host) is shown as an example.
Execute the following command to check the container ID.
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1c8caa876b98 httpd:2-alpine "httpd-foreground" 24 hours ago Up 24 hours 0.0.0.0:8080->80/tcp fluentd_docker_httpd_1
From the above command, I found that the container ID is 1c8caa876b98
.
Execute the following command to copy the file
//docker cp [Container ID]:[File path you want to copy] [The path you want to copy locally]
$ docker cp 1c8caa876b98:/usr/local/apache2/conf/httpd.conf conf/
$ ls conf/
./ ../ httpd.conf
I was able to copy!
--Copy from docker container to host --Use docker cp command
docker cp [Container ID]:[File path you want to copy] [The path you want to copy locally]
Recommended Posts