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. :-)