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

--ssh option does not work in wp-cli container #621

Open
haynzz opened this issue Jun 30, 2021 · 4 comments
Open

--ssh option does not work in wp-cli container #621

haynzz opened this issue Jun 30, 2021 · 4 comments

Comments

@haynzz
Copy link

haynzz commented Jun 30, 2021

I have tried running wp with the --ssh option on wordpress:cli-2-php7.4
I get an error that basically says that ssh cannot be found.
So, I assume ssh is not installed for that image.

@tianon
Copy link
Member

tianon commented Jun 30, 2021

Correct -- using SSH inside a container is a bit unique. Can you describe the use case in a bit more detail?

@haynzz
Copy link
Author

haynzz commented Jul 1, 2021

Thanks for getting back to me so quickly.
I am managing my wordpress instances with git and composer. Which means installing plugins etc totally under version control.
I want to reduce the amount of things that I do on the admin UI, so that I can assure the different environments (local, staging, production) are the same. When I install a plugin via composer I want to activate it via WP–Cli.
I thought it may come in handy if I could run wp-cli from the CI-container and I planned using this wp-cli image for that.
I was thinking I would not need to maintain wp-cli installations/version on the hosting server this way.
Fast forward, I now realised that I can't consistently follow-through with this approach, since composer does not offer ssh.
Still, I thought it's worth mentioning that a documented wp-cli feature is blocked by the way the container image is built.
I think it should at least be mentioned in the documentation of the image somewhere.

@tianon
Copy link
Member

tianon commented Jul 1, 2021

I appreciate the added detail.

The reason I'm still hesitant is because using even just the SSH client inside a container is pretty complex, especially since you'll ideally be using key-based authentication, so you need to get the (private!) keys from your host into the container in precisely the right place for them to get picked up, so it's fiddly enough that it seems pretty reasonable to expect users who need that to install openssh-client themselves, especially since it'll install so quickly (apk add --no-cache openssh-client).

@haynzz
Copy link
Author

haynzz commented Jul 3, 2021

Yeah, good point.
That's also what I've done in the end. I created my own Docker image from this one.
It took me a while though to figure out that I had to add USER root before the above install command.
In my exact case I could have used password instead of key-based authentication, but with CI it's correct what you say.
I'd still like to add that it didn't seem more complex for me to get SSH running in a container than it is on my host machine. So, if you want ssh you will have to know what you're doing no matter if it's a docker container or on my host machine. I normally try to use existing docker images instead of creating my own Dockerfiles and building them. Specifically because then I have to push them to a registry or something so they work with CI. So, that version was much more fiddly for me. And as I have mentioned there was no easy way for me to install openssh-client while in a running wp-cli container because of permission problems. sudo did not work and I could also not switch to root.
As I said, It's probably just worth mentioning that you'll need to fork-off your own Image to be able to use the --ssh option in the README or where-ever.

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

No branches or pull requests

2 participants