Skip to content
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

passing stdin to command for docker-based WP instances #4972

Open
drzraf opened this issue Oct 12, 2018 · 7 comments
Open

passing stdin to command for docker-based WP instances #4972

drzraf opened this issue Oct 12, 2018 · 7 comments

Comments

@drzraf
Copy link

drzraf commented Oct 12, 2018

PR #4240 did not considered using the docker exec --interactive option.
That causes problem when it comes to passing stdin to wp-cli, for example wp db import

@drzraf drzraf changed the title passing stdin to command docker-based WP instances passing stdin to command for docker-based WP instances Oct 12, 2018
@schlessera
Copy link
Member

Yes, indeed. Are you up for providing a PR for that?

@drzraf
Copy link
Author

drzraf commented Oct 24, 2018

Sorry, I currently can't do it. (@chriszarate maybe ? :))

@schlessera
Copy link
Member

No need to be sorry, pointing out the issue was already a win for the project! So, thanks for that! :)

@jserrao
Copy link

jserrao commented Apr 8, 2019

I wonder if this has something to do with an error I'm seeing. I make use of Lando (https://github.com/lando/lando), which is a slick set of WP-centric containers that run through Docker. I upgraded to their latest release, which seems to have made wp-cli confused.

I get DB connection errors just typing wp on the command line inside of any of my Lando/docker-based WP local machines. But...the machines work just fine, which indicates to me something deeper is going on and the error message info isn't accurate.

Anything I can help to debug, like logs?

Error establishing a database connection. This either means that the username and password information in your `wp-config.php` file is incorrect or we can’t contact the database server at `database`. This could mean your host’s database server is down.

@legoblokje
Copy link

legoblokje commented Aug 26, 2020

I think I'm running into this issue while importing/exporting a database. I am getting the following message:the input device is not a TTY and the database dump fails to import.

My situation:
Local host (MacOS) with Docker container running Wordpress
Remote host (Ubuntu Server) with Docker container running Wordpress

My local wp-cli.yml:

@local:
    ssh: docker-compose:wordpress-image

@remote:
    ssh: remote

My remote wp-cli.yml:
ssh: docker-compose:wordpress-image

My command:
wp @remote db export - | wp @local db import -

It will work when I run it in reverse:
wp @local db export - | wp @remote db import -

@legoblokje
Copy link

Little update on this: I forced the command to run with -T and the import runs succesfully. The code in question is found at:
https://github.com/wp-cli/wp-cli/blob/master/php/WP_CLI/Runner.php#L526

The Docker Compose documentation describes the -T option as follows:

Disable pseudo-tty allocation. By default docker-compose exec allocates a TTY.

@schlessera I'm a bit out of my depth here and I'm not sure what's the best way to approach this, but I would like to help and maybe submit a PR. Should the pseudo-tty be disabled by default on wp db import? Or are there situations where TTY is desired on wp db import?

@ideag
Copy link

ideag commented Apr 12, 2021

I ran into the input device is not a TTY as well.

my wp-cli.yml

@devdc:
  ssh: docker-compose:user@servicename
  path: /path/to/wp/
@devdocker:
  ssh: docker:user@containername
  path: /path/to/wp/

If I try to run a simple command, it will work, no problem:
wp @devdc user list --field=ID
But if I try to chain a couple of commands together, it will fail with the input device is not a TTY, for example, this:
wp @devdc user list --field=ID | xargs -I %% wp @devdc post list --author=%% --status=publish

This issue seems to only affect the docker-compose "protocol", if run them through docker protocol, it all works as expected:
wp @devdocker user list --field=ID | xargs -I %% wp @devdocker post list --author=%% --status=publish

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants