{"id":4489,"date":"2025-04-23T13:23:18","date_gmt":"2025-04-23T13:23:18","guid":{"rendered":"https:\/\/geekmungus.co.uk\/?p=4489"},"modified":"2025-04-23T13:23:19","modified_gmt":"2025-04-23T13:23:19","slug":"copy-file-from-docker-container-to-host","status":"publish","type":"post","link":"https:\/\/geekmungus.co.uk\/?p=4489","title":{"rendered":"Copy File from Docker Container to Host"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Let&#8217;s say you have a running Docker Container and you need to copy a file from it down to the host, you might need to do this while building a Docker image perhaps to see what a file that has been autogenerated looks like for example. You can do this by running the following from the host:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker cp &lt;containername>:\/&lt;src_path> &lt;dst_path><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can of course to the reverse, to copy from the host to the container with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker cp &lt;src_path> &lt;containername>:\/&lt;dst_path><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Having a look at a real example, here I had a container called &#8220;v7&#8221; where I wanted to copy the &#8220;shibboleth2.xml&#8221; file from \/etc\/shibboleth\/ directory, so i&#8217;d use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker cp v7:\/etc\/shibboleth\/shibboleth2.xml .<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s say you have a running Docker Container and you need to copy a file from it down to the host, you might need to do this while building a Docker image perhaps to see what a file that has been autogenerated looks like for example. You can do this by running the following from &#8230; <a title=\"Copy File from Docker Container to Host\" class=\"read-more\" href=\"https:\/\/geekmungus.co.uk\/?p=4489\" aria-label=\"Read more about Copy File from Docker Container to Host\">Read more<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-4489","post","type-post","status-publish","format-standard","hentry","category-random"],"_links":{"self":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/4489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4489"}],"version-history":[{"count":1,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/4489\/revisions"}],"predecessor-version":[{"id":4490,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/4489\/revisions\/4490"}],"wp:attachment":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}