1

I trying to copy a file from a container to my local machine.

As you can see below, my container is runnig... ❯ docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1cbed27defce postgres "docker-entrypoint.s…" 17 months ago Up 44 minutes 0.0.0.0:5432->5432/tcp pg

When I use the docker cp command, I have this output...

❯ sudo docker cp pg:recom.bkp /home/melnik/dev/recom                  
[sudo] senha para melnik: 
Error response from daemon: No such container: pg

I've already tried the command docker exec pg pwd to get the correct path, but the output is just /

5
  • Why are you using sudo? Commented Feb 13, 2024 at 2:05
  • Does it work if you use the container id? docker cp 1cbed27defce:recom.bkp /home/melnik/dev/recom Commented Feb 13, 2024 at 2:10
  • Are you using Docker Desktop? Since sudo changes your user identity and home directory, it's possible that docker and sudo docker are pointed at different Docker daemons. If you're on a native-Linux system and sudo docker ... works, you don't really need Docker Desktop. Commented Feb 13, 2024 at 3:55
  • If I run the command without sudo, the output is: ❯ docker cp pg:/recom.bkp /dev Successfully copied 32.8kB to /dev open /dev/recom.bkp: permission denied Commented Feb 13, 2024 at 22:57
  • Whoa, don't write into /dev, that's a very bad idea. See baeldung.com/linux/dev-directory Commented Feb 14, 2024 at 0:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.