-1

I'm stumped on an interesting issue: I am attempting to execute a command that copies a local file to a Postgres Docker container. The code:

command = "docker cp /tmp/app/dump.sql postgres-app:/tmp/postgres/backup/"
process = subprocess.Popen(
    shlex.split(command), stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
stdout, stderr = process.communicate()

Strangely, stderr returns:

lstat /private/tmp/app/dump.sql: no such file or directory

I am executing these commands from this directory on my Mac:

/Users/my-name/path/to/project

Based on my research, the /private directory referenced in the error appears to be a Mac filesystem feature. It seems that the incorrect directory reference (with /private prepended) is being passed to the subprocess by Python, and I am unsure of how I can correct that.

Thanks for any and all help... I am testing this functionality locally, but this file will eventually be deployed to a vanilla Linux environment where the /private directory will not be a problem. This is just a very peculiar issue. :-)

ffej
  • 73
  • 2
  • 7
  • Please specify the directory from which you are executing `docker` command. Check above thread – Digvijay S May 08 '20 at 05:08
  • Does this answer your question? [Docker: "lstat no such file or directory" error when building image. File is there](https://stackoverflow.com/questions/36180296/docker-lstat-no-such-file-or-directory-error-when-building-image-file-is-the) – Digvijay S May 08 '20 at 05:08
  • @DigvijayS unfortunately, I'm using a pre-built image straight from Postgres, so no Dockerfile or build context is involved. Updating the question with the directory this is run from. – ffej May 08 '20 at 05:13

1 Answers1

-1

Well, silly me. dump.sql was named backup.sql. I don't know how many hours I spent on this... Always start with the most obvious stuff, folks. Case closed.

ffej
  • 73
  • 2
  • 7