In this post I’ll run over how to setup WP-CLI on a Docker web server image ( so you can easily use it todo a Database find and replace , would is handy when you need to migrate a site from one place to another ).
This presumes you have PHP setup on the command line (which my image did have ). Anyway here goes:
- First in your Docker folder run ‘docker ps’ ( to get the name of the web server image CONTAINER ID )
- Pop that into this command e.g. ‘docker exec -it fdghye5742252 bash’
- You’ll be in a shell on the web server now
- navigate to your web root of the site you want ( my image puts me there already eg /var/www/html )
- download wp-cli and install see https://make.wordpress.org/cli/handbook/guides/installing/
- you can also do this on a volume if you have your webroot setup as a volume linked to your local hard drive
- I didn’t bother with moving it to the bin dir (which would put it on the global path)
- I just did ‘mv wp-cli.phar wp’
- you can then run eg
- ‘./wp –info’
- do your find and replace ‘./wp search-replace ‘https://www.somesite.co.uk’ ‘http://localhost’ –allow-root’
Disclaimer – Obviously with anything like this be careful and make sure you have a backup, use at your own risk.
Disclaimer: All content on this site, is use at your own risk (Always backup before changing anything in your software/database/servers etc). Techs change, go out of date etc...
I/we accept no liability if anything you use on this site adversely affects you.
Recent Comments