Error in "docker-compose" when I use pipe with sh (echo "docker-compose ..." | sh)

I have an application with several containers. For easy installation, I decide to use the packaging image. I expected below

$ docker run my_application install | sh 

-> pull out all related images from the registry

 $ docker run my_application up | sh 

-> complete the initial task and all containers

But I ran into a problem below.

 $ echo "docker-compose exec cassandra cqlsh -e 'desc keyspaces'" | sh Traceback (most recent call last): File "<string>", line 3, in <module> File "compose/cli/main.py", line 57, in main File "compose/cli/main.py", line 108, in perform_command File "compose/cli/main.py", line 353, in exec_command File ".tox/py27/lib/python2.7/site-packages/dockerpty/pty.py", line 338, in start File ".tox/py27/lib/python2.7/site-packages/dockerpty/io.py", line 32, in set_blocking ValueError: file descriptor cannot be a negative integer (-1) docker-compose returned -1 

error arising from docker-compose command. when you try, as shown below, it works well.

 $ echo "docker exec my_application_cassandra_1 cqlsh -e 'desc keyspaces'" | sh system_traces system $ sh -c "docker-compose exec cassandra cqlsh -e 'desc keyspaces'" system_traces system 

but when I use a tube with docker layout it always puts an error.

Does anyone have any ideas how I can handle this?

+5
source share
1 answer

This will open the error in the docker-compose file.

As a workaround, you can pass the -T option to docker-compose exec :

 $ docker-compose exec --help [...] -T Disable pseudo-tty allocation. By default `docker-compose exec` allocates a TTY. 
+8
source

Source: https://habr.com/ru/post/1247490/


All Articles