Search code examples
dockerubuntuscp

How to transfer / copy files from docker container to local directory in ubuntu 18.04?


I am using ubuntu 18.04 with virtual machine for running my program in remote GPU server. I ran my program in docker and I want to transfer plot files in docker container to local file directory in my virtual machine. I used scp to transfer local files from virtual machine to docker container, but now I want to transfer result of my program, plot file back to local file directory in my virtual machine. How can I do this in ubuntu? any idea?

here is what I did previously:

scp -P 8080 ./Downloads/my_func.py uid@cumulus.nlp.stanford.edu:data

for me, transferring files from local to remote docker container works pretty good, but reverse is not working or I made somewhere wrong in the command.

and this is list of files that currently resided in docker container(from docker shell):

root@d3576359f9ac:/data# ls
cnn_mobnet.py              cnn_ResNet50.py  cnn_mobnet_v1.py
cnn.py    cnn_mobnet_loss_curve.png  cnn_00.py        mobnet_test.py

my attempt:

I tried to copy cnn_mobnet_loss_curve.png to local file directory in my virtual machine, but it doesn't work:

scp data/cnn_mobnet_loss_curve.png :./Downloads

I also tried docker cp data/cnn_mobnet_loss_curve.png :./Downloads but it gives me error said docker command is not recognized. Any thought?

where I want to copy or transfer cnn_mobnet_loss_curve.png to ./Downloads which is in my virtual machine. How can I make this right? Any idea to transfer files from remote docker container to local in ubuntu? How can I do this from terminal in Ubuntu? any idea?


Solution

  • I think you can do something like. Try this from your terminal:

    me@myvirtualbox: ~$ scp -p 8080 uid@cumulus.nlp.stanford.edu:data/plot.png ./Downloads
    

    you should provide your password for remote endpoint, and above solution should works for you.