New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error on launching docker-compose by piping to sh ( echo 'docker-compose ... ' | sh ) #3352
Comments
I'm having the same problem, when piping Here's the command:
(I have that line in a backup script that I run sometimes manually (works fine) and sometimes as a cron job (won't work)). Now I've worked around my problem by calling Docker directly like so:
— works fine from both Cron and manually in Bash. |
I do have the same issue when using something like
does not work - neither as a one-liner in the crontab, nor as a shell script called from crontab I could create a workaround with bash script like:
|
I could get it to work by adding the
|
The -T option worked for me, but the script doesn't return to command prompt even after it finishes the last command. |
I'm having the same issue when running: Everything seems to work after all (the command executes as expected), it's just that nasty crash that docker-compose gives me afterwards:
When I use the |
Traceback (most recent call last): |
I have the same problem, but just by launching this from jenkins (it fails just there): |
Same here. |
Have you tried adding the -T flag to docker-compose exec? |
Tried it now, adding |
To test I have a basic python script that just prints stdin
|
What happens when you add a -u to the first line in your Python script
(#!/usr/bin/python -u)? I guess your output is buffered.
On Mon, 9 Jan 2017, 19:38 Leon Blakey, ***@***.***> wrote:
-T isn't working for me. My only workaround is to use docker exec
directly but means I have to parse the container ID from docker ps which
isn't ideal.
To test I have a basic python script that just prints stdin
$ cat myScript.py
#!/usr/bin/python
import sys
print "started"
for line in sys.stdin:
print line
$ echo test | docker-compose exec -T myContainer /usr/src/myScript.py
.. nothing happens, just waits ..
$ echo test | docker-compose exec myContainer /usr/src/myScript.py
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "compose/cli/main.py", line 65, in main
File "compose/cli/main.py", line 117, in perform_command
File "compose/cli/main.py", line 462, in exec_command
File "site-packages/dockerpty/pty.py", line 338, in start
File "site-packages/dockerpty/io.py", line 32, in set_blocking
ValueError: file descriptor cannot be a negative integer (-1)
docker-compose returned -1
$ echo test | docker exec -i d6380314bb89 /usr/src/myScript.py
started
test
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3352 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABI3M4d_POesl4j9JdLn8eY4Z4K1DVGmks5rQn6pgaJpZM4ILWjn>
.
--
Michaël Arnauts
|
I'd say that the problem is that
|
env: ansible playbook + ubuntu(vagrant) error: Traceback (most recent call last):
File "/usr/local/bin/docker-compose", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", line 65, in main
command()
File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", line 117, in perform_command
handler(command, command_options)
File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", line 462, in exec_command
pty.start()
File "/usr/local/lib/python2.7/dist-packages/dockerpty/pty.py", line 338, in start
io.set_blocking(pump, flag)
File "/usr/local/lib/python2.7/dist-packages/dockerpty/io.py", line 32, in set_blocking
old_flag = fcntl.fcntl(fd, fcntl.F_GETFL)
ValueError: file descriptor cannot be a negative integer (-1) add |
for all those curious about getting around this while still getting information from docker-compose... docker exec -i $(docker-compose ps -q cassandra) < someexample.cql The -i keeps stdin open while not allotting a tty and the I assume this will provide multiple IDs if you have many running, you'll have to do some munging to use this method. It would appear docker-compose isn't implicitly using a |
Just want to leave this minimal test-case for docker-compose:
It triggers error:
|
I can reproduce this bug just when docker-compose gets called from jenkins or gitlab-ci |
Same here in Jenkins. |
What is |
I think he means you can use
|
also fails for me, but with
it just produce empty file, so no any output! Even there no error, it is unusable. |
work around docker/compose#3352
work around docker/compose#3352
So, as I understand, |
|
`docker-compose exec` throws an exception after running a command if `docker-compose` is ran via a cron. A workaround is to run the command via `docker exec` instead. docker/compose#3352
I would add a bit of changes for someone who have a container-name set .Based on @michaelarnauts |
This prevents alloction of a pseudo-TTY when it is not necessary, as suggested in docker/compose#3352
While the `renew_certificate.sh` script worked fine when I ran it manually, it didn't appear to be running via the `crontab` (based on the lack of StatsD metrics going to my DataDog agent). After piping the output of the `crontab` to a file, I found two issues. First, the output was: > the input device is not a TTY This was caused by the `-it` options in my `docker run` command. The `-t` requires a TTY interface to be allocated; which, is not allocated when running via `crontab`. Once I removed the `-it` options, I was faced with a second error in the log output: ``` Traceback (most recent call last): File "bin/docker-compose", line 6, in <module> File "compose/cli/main.py", line 71, in main File "compose/cli/main.py", line 124, in perform_command File "compose/cli/main.py", line 467, in exec_command File "site-packages/dockerpty/pty.py", line 338, in start File "site-packages/dockerpty/io.py", line 32, in set_blocking ValueError: file descriptor cannot be a negative integer (-1) Failed to execute script docker-compose ``` Apparently, this is a known issue with `docker-compose` being run inside a script, like `crontab`. To work around this, adding the `-T` option tells docker not to allocate a Pseudo-TTY for `docker-compose`. Source: https://stackoverflow.com/questions/43099116/the-input-device-is-not-a-tty Source: docker/compose#3352
Without it, the following error occurs when run with cron: ValueError: file descriptor cannot be a negative integer (-1) See docker/compose#3352.
now I try in cron (again)
now I have same problem in cron (again)
after add into
https://stackoverflow.com/a/10657111/7670492 I try again with
success |
See the [helm docs](https://docs.docker.com/v17.09/compose/reference/exec/) for the `-T` flag explanation. When running this as a startup-script as shown in the [Mender solution doc](https://cloud.google.com/community/tutorials/cloud-iot-mender-ota) we run into [this error](docker/compose#3352). Disabling pseudo-tty creation fixes it.
See the [helm docs](https://docs.docker.com/v17.09/compose/reference/exec/) for the `-T` flag explanation. When running this as a startup-script as shown in the [Mender solution doc](https://cloud.google.com/community/tutorials/cloud-iot-mender-ota) we run into [this error](docker/compose#3352). Disabling pseudo-tty creation fixes it.
I've a application which has multi container. to easy installation, I decide to use package image which contains docker-comopse.yaml file.
what I expected is like below
$ docker run my_application install | sh
this will pull all related image
$ docker run my_application up | sh
this will do "docker-compose up" and some intial job for application using "docker-compose exec"
But I got below error
and I confiremd that below two commands works well
Does someone have any idea why the error comes?
below is my version info and logs from docker-compose
The text was updated successfully, but these errors were encountered: