"docker cp" in a script: "cannot enable tty mode on non tty input"

Hi

I’m using “docker cp” wrapped in a perl script, run from cron, to copy a file into a container.
However, debugging it I see this command fails with:

“cannot enable tty mode on non tty input”

Would anyone know how to workaround this? The script runs fine manually, and other aspects of running from cron run fine.

Thanks in advance!

just add #!/bin/sh at beginning of your script. Or if still it doesn’t work then replace #!/bin/sh with #!/bin/bash

To all the beginners: don’t make this a habit. A workflow relying on docker cp sounds wrong on so many levels…

Valid usecases for docker cp are:
– when you need a config file to start the container, which does not get generated/copied when you bind a host folder into the target. Copy the files to the host, recreate the container and this time use volumes to map the config file back into the container.
– when you want to export one shot debug or logging information from the container to the host (if this happes regularly: use volumes and/or log management!).
– when you forget to mount a volume to persist stateful data on the host, and now you want to “export” the data to the host, so you can delete the container and re-create it with a bind-mount to the host folder you copied the files to.

#3 typical happens to beginners and allows to fix a wrong doing, 2 usualy happes during troubleshootings, #1 can be reoccurring, depening on the images you us.