How do I copy a file from docker container to host?

0 votes

I don't want to install all the runtimes and libraries on the agents themselves so I am thinking to use docker to build my dependencies on a continuous integration server. To achieve this I would need to copy the build artifacts that are built inside the container back into the host.

How do I do that?

Can anyone help me with this.

Thanks

Aug 27, 2018 in Docker by Damon Salvatore
• 5,250 points
671 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+1 vote

Here is a way which you can try if you want to copy a file from a container to the host. you can use the below command:

docker cp <containerId>:/file/path/within/container /host/path/target

Here's an example:

[sam@dev]$ sudo docker cp goofy_roentgen:/out_read.jpg .

Here goofy_roentgen is the name I got from the following command:

[sam@dev]$ sudo docker ps
[sudo] password for jalal:
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                                            NAMES
1b4ad9311e93        bamos/openface      "/bin/bash"         33 minutes ago      Up 33 minutes       0.0.0.0:8000->8000/tcp, 0.0.0.0:9000->9000/tcp   goofy_roentge


I hope it will resolve your query.

answered Aug 27, 2018 by Damon Salvatore
• 5,250 points

Related Questions In Docker

+4 votes
4 answers

How To Access a Service on Host From a Docker Container?

Adding to kalgi's answer, You can also ...READ MORE

answered Oct 16, 2018 in Docker by lina
• 8,100 points

edited Oct 16, 2018 by lina 1,975 views
0 votes
1 answer
0 votes
2 answers

How to edit file after I shell to a docker container?

You can even install it using a ...READ MORE

answered Apr 23 in Docker by Ashish
1,709 views
0 votes
1 answer

How to run a docker command from inside the container?

You must have come across the /var/run/docker.sock file, ...READ MORE

answered Jun 28, 2018 in Docker by Sophie may
• 9,050 points
214 views
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,120 points
56 views
0 votes
1 answer

How do I run a docker image as a container?

You can run an image depends on whether you ...READ MORE

answered Sep 7, 2018 in Docker by Damon Salvatore
• 5,250 points
30 views
0 votes
1 answer

How do I force Docker for a clean build of an image ?

You can try the following step: You have ...READ MORE

answered Sep 7, 2018 in Docker by Damon Salvatore
• 5,250 points
192 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.