Code Monkey home page Code Monkey logo

wsl2-docker-wpcli-issue's Introduction

My heart’s desire:

access WP-CLI functions in WordPress docker in Ubuntu

Environment:

Windows 10 Home with Hyper-V enabled; WSL2; Docker Desktop with WSL2 support enabled; Ubuntu 20.04

To achieve this (as far as my understanding):

  • WP and WPCLI should be sharing the same volume, and the same network
  • I need to pass the same variables to WPCLI as to WP (changes from March 2021 here)
  • The IP address that WSL uses changes whenever the computer is restarted.
  • Ubuntu user has to be specified for WPCLI, www-data for WP and www-data user for WPCLI have different ids https://www.buzzphp.com/posts/how-to-run-wp-cli-in-docker-composeyml

Result so far:

unnamed $ docker-compose up -d

Then in WP root:

$ wp user list

Error: This does not seem to be a WordPress installation.

I was not able to pass the path recognized properly as well (see below).

I tried 2 ways to achieve this, both are getting me closer but still not there.

Way #1 not named volumes, WP installation in the directory where docker-compose.yml is located

docker-compose.yml for this https://github.com/sabrina-zeidan/wsl2-docker-wpcli-issue/blob/main/docker-compose-not-named-volumes.yml

Why it doesn’t work:

I believe that not named volumes, though having the same location don’t get bundled together, so WPCLI has no idea there is WP there.

Way #2: named volumes, WP installation god knows where

docker-compose.yml for this: https://github.com/sabrina-zeidan/wsl2-docker-wpcli-issue/blob/main/docker-compose-named-volumes.yml

Why it doesn’t work:

This seems like it should work in the end. The problem I encountered here is that** I just can’t navigate to WP installation folder in Ubuntu.**

In WSL2 containers are not accessible from ubuntu by default, they can be located in Windows but not in Ubuntu
This worked for me: microsoft/WSL#4176 (comment)
But just once, after PC restart it doesn’t work anymore, I tried the last answer in that thread — didn’t make a trick. This is related microsoft/WSL#3854 (comment)

This MySQL sleep thing worked for me! But just one time as well.

https://question-it.com/questions/3371307/kak-zapustit-wp-cli-v-docker-composeyml

UPD: about making WSL2 communicate with Windows installs https://anchor.host/local-lightning-and-upgrading-to-wsl2/

wsl2-docker-wpcli-issue's People

Contributors

sabrina-zeidan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.