Open schlessera opened 7 years ago
The real fix would be to replace the mysql
binary with mysqli
or PDO
, of course, but for some of the commands we're using, this is not a small task.
So, instead of blindly running
mysql
locally, WP-CLI could check whether there's such a configuration setting, and then first log into the actual database server that the SSH settings are pointing to and then run themysql
binary from that database server.
A couple of questions:
mysql
on the web container?mysql
to a SSH connection string?how is this less-complex of a solution than installing mysql on the web container?
I read those issues but I have same question. If I want to use wp-cli in a docker container, I always write dockerfile like following.
RUN apt-get update -y && apt install mysql -y \
su -l ubuntu bash -lc 'wp core download ...' \
su -l ubuntu bash -lc 'wp config create ...' \
Or run
$ docker run -idt -p 80:80 -p 443:443 ...
$ docker exec --user ubuntu --tty example.com env TERM=xterm apt install xxxx"
It looks easier than refactoring wp-cli.
I don't have many experience with docker, so I want to know the problem if we install mysql client into docker container.
Does Docker typically permit SSH connections to database containers?
I'm not sure, that's why I wanted to investigate this.
how is this less-complex of a solution than installing
mysql
on the web container?
It's not so much about complexity, but more about the principles behind containers. If you install database drivers on your web server container, it partially defeats the purpose of using containers in the first place. So, while there are working solutions right now, none of them really fits within the way containers should work.
Could the same solution be achieved by aliasing
mysql
to a SSH connection string?
I guess if the first question can be answered with "yes", then this one will be the same.
If you are running the wp-cli inside alpine container you only need to install mysql-client which only takes 4kB when installed.
Right now, people using Docker have trouble setting up WP-CLI correctly. They either need to install the
mysql
on their web server as well (instead of only on their database server), or use a separate WP-CLI container altogether.I was now thinking that it might be possible to allow for a configuration setting that defines an SSH connection to use for the
mysql
binary. So, instead of blindly runningmysql
locally, WP-CLI could check whether there's such a configuration setting, and then first log into the actual database server that the SSH settings are pointing to and then run themysql
binary from that database server.I'm not 100% clear on whether this would all techincally work, but it would certainly be worth some time to investigate.