NOt able to copy file from docker server to container , although container is there
e68422e4a84fc7a329c65cc3835f6a2f138ed1682b2d8a0f0d29abfb595ac95e
shyam@DESKTOP-OO7EVK2:/$ docker cp port01.txt web001:/
lstat //port01.txt: no such file or directory
shyam@DESKTOP-OO7EVK2:/$ docker cp port01.txt web01:/
lstat //port01.txt: no such file or directory
shyam@DESKTOP-OO7EVK2:/$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e68422e4a84f nginx "/docker-entrypoint.…" 54 seconds ago Up 54 seconds 0.0.0.0:8081->80/tcp web002
f872d2e868a9 nginx "/docker-entrypoint.…" About a minute ago Created web001
4a4c9e4d46ad nginx "/docker-entrypoint.…" 18 minutes ago Up 18 minutes 0.0.0.0:8080->80/tcp port01
Did you really create a file in the Linux root? Unless you did it as a root user, you don’t even have permission to do that. If the file is not there, as the error message cleary says, it is normal to have the error message.
Nothing at all indicated in the error message that the container is not there. It is the file which is not there.
I have not used sudo but with out sudo when I created file using touch command it did not give any error .
however I tried now with sudo, even I am trying to give right password it is not allowing me to proceed further. could you please advise on this ?
The ls -l command must be done in the folder where you want to use docker cp.
Note: if you use docker cp for anything else than “testing something out” or copying files from the container to the host, you most likely try to do something that either should be done by binding a host folder as volume, or by creating a new image where the file is copied into the image.
Please, format your post according to the following guide: How to format your forum posts
In short: please, use </> button to share codes, terminal outputs, error messages or anything that can contain special characters which would be interpreted by the MarkDown filter. Use the preview feature to make sure your text is formatted as you would expect it and check your post after you have sent it so you can still fix it.
Example code block:
```
echo "I am a code."
echo "An athletic one, and I wanna run."
```
After fixing your post, please send a new comment so people are notified about the fixed content.