Ivan
Ivan

Reputation: 7746

Copy file from docker container to local host

I have a docker container

CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS                    NAMES
44758917bf50        jupyter/pyspark-notebook   "tini -g -- start-no\u2026"   4 hours ago         Up 4 hours          0.0.0.0:8888->8888/tcp   thirsty_lamport

Inside I am running jupyter notebook. I have an ipynb that I would like to copy. Inside of the notebook, I see what the current directory is by typing pwd

[in 42] pwd
[out 42]'/home/jovyan'

If I now say from the host machine:

idf@ubvm:~/Documents$ docker cp 44758917bf50:/root/jovyan/pysparkex.ipynb ./pyex.ipypnb

I get an error:

Error: No such container:path: 44758917bf50:/root/jovyan/pysparkex.ipynb

I get an error no matter what path I choose, so for example same error if I remove 'root' from the path above.

What am I doing wrong?

EDIT

This got me much further:

idf@ubvm:~/Documents$ docker exec 44758917bf50 ls /home/jovyan
pysparkex.ipynb
Untitled.ipynb
work

Now I have to figure out what the docker cp command is.

Upvotes: 1

Views: 325

Answers (1)

ziegler zhang
ziegler zhang

Reputation: 46

Seems you confused the source dir in container and target dir in local machine, try docker cp 44758917bf50:/home/jovyan/pysparkex.ipynb ./pyex.ipypnb

Upvotes: 3

Related Questions