Updating wordpress plugins inside a docker container
Here is my scenario:
I have been developing a plugin which will be modified very often, I need to create an image using docker in which install a fresh version of wordpress and then import all the database and plugins from the development environment, ( The plug in is on github)
I managed to install wordpress on docker using https://github.com/eugeneware/docker-wordpress-nginx
Now here are my questions:
1-is there any way to modify the wordpress files and folders after it’s been installed in docker(for installing plugins and using command line, not the wordpress GUI)
2-If I want to achieve what I explained above what is the best workflow?
Two possible answers to your problem. I’m struggling with this right now as well, so YMMV.
First, if you’re running the Docker container on your host, you can always pause it
docker pause, create a new image from the running container
docker commit, then push it to a private repository
docker push (a live WordPress install is probably not appropriate for the public Docker Hub). Once that’s done, you can resume the container
docker unpause and then you can go update the image on your dev system. Then come back once the upgrade is in and tested and all is good, and then
docker pull the image and restart your service so it uses the new image.
Not a great solution, but it will work.
Based on the comment by Tadeusz, I wouldn’t necessarily run your whole WP install from a data volume. They are volatile and if, for any reason, your container gets deleted and it’s the only one referencing the data volume, then you lose everything (unless you keep multiple backups — you do keep multiple backups, right?)
The other solution I’m considering is having plugin changes be deployed as part of the Dockerfile. A much more deliberate approach, but can be webhooked such that it automatically builds a new Docker image when you commit to your Github repo. There’s discussion of doing that automatic build process here.
The server admin end of things on your end hosting will need to pull a the new image as I mentioned above. And done.
Of course, setting this up is left as an exercise for your dev system.
Late to the party but I’ve got a decent solution to this. It isn’t covered by the other answers and should also be useful to future readers.
I’m comfortably running this on an ec2 t2-micro box and so far it’s worked perfectly. WordPress, mySQL and Nginx are all installed in their own containers (via Docker compose) and Docker volumes are used to maintain both mySQL and WordPress state. Code and additional info about the Nginx setup taken from here.
version: '3.6' services: db: image: mysql:5.7 volumes: - db_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: db_root_pass MYSQL_DATABASE: db MYSQL_USER: db_user MYSQL_PASSWORD: db_pass nginx: depends_on: - wordpress image: nginx:latest restart: always ports: - "80:80" volumes: - ./nginx.conf:/etc/nginx/nginx.conf wordpress: depends_on: - db volumes: - wp_data:/var/www/html/wp-content image: wordpress:latest restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: db_user WORDPRESS_DB_PASSWORD: db_pass volumes: db_data: wp_data:
db_data volume is mapped to the mySQL data directory within the mySQL container and the
wp_data volume is mapped to the WordPress content directory in the WordPress container. What you can do is configure the CLI to write to the
wp_data directory on the host and those changes will be revealed on the WordPress site without needing to rebuild any containers!
- Database Administration Tutorials
- Programming Tutorials & IT News
- Linux & DevOps World
- Ebook Reviews
- PES Matches, Skills & News