Plugin not working in Wordpress installed via Docker - wordpress

I am beginner in docker and have setup wordpress in Docker. Everything was working fine except some plugin not working well as they should be. In my understanding, docker needs some volume mounted to work but i can't find any location of where they might be. For eg. it says "Wordpress copying /var/ww/html but there is actually nothing. The main problem was when i wanted to convert wordpress into Static site but the plugin simply static cant't generate the files in localhost.
I am running docker Server Version: 17.09.0-ce in Ubuntu 17.04 and
here is my docker-compose configuration.
docker-compose.yml
wordpress:
image: wordpress
links:
- wordpress_db:mysql
volumes:
- ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
ports:
- 8080:80
wordpress_db:
image: mariadb
environment:
MYSQL_ROOT_PASSWORD: examplepass
phpmyadmin:
image: corbinu/docker-phpmyadmin
links:
- wordpress_db:mysql
ports:
- 8181:80
environment:
MYSQL_USERNAME: root
MYSQL_ROOT_PASSWORD: examplepass

Install php-zip and the plugin will actually start to work.

Related

Is restarting a website with "docker-compose up" after a host server reboot a standard practice?

I created a Wordpress website with the docker-compose.yml below.
I started it with docker-compose up -d (Note that the MySQL and Wordpress data are persisted in subdirectories of the local directory: ./mysql and ./wp).
Then let's say we reboot the host server.
How would you restart these containers/this website?
Would you just redo docker-compose up -d?
I tried, and it works indeed, but this actually recreates
new containers! Fortunately, as it reuses the same data directories and as it detects that /var/www/html is non-empty, a new Wordpress installation is not triggered, so "everything is ok", but still, isn't recreating new containers bad practice since the website already exists?
Is there a more "graceful" way to restart containers made with docker-compose after host server reboot, rather than "recreating" the containers?
version: '2'
services:
db:
image: mysql:5.7
volumes: ['./mysql:/var/lib/mysql']
restart: always
environment:
MYSQL_ROOT_PASSWORD: abcdef
MYSQL_DATABASE: wordpress
MYSQL_USER: wp
MYSQL_PASSWORD: abcabc
wordpress:
depends_on: ['db']
image: wordpress:latest
volumes: ['./wp:/var/www/html']
ports: ['8000:80']
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wp
WORDPRESS_DB_PASSWORD: abcabc
There are 2 ways to start containers which are created by docker-compose.
After rebooting the machine:
Run: docker ps -a to show all stopped-container, and you can start container manually, docker start [container_name or container_id]
Run: docker-compose start [service].
Starts existing containers for a service.
In your case:
docker-compose start db
docker-compose start wordpress
or just
docker-compose start
Starting db ... done
Starting wordpress ... done
Before rebooting, docker-compose stop.

How to backup dockerized wordpress on linode?

I deployed wordpress to linode using docker-compose for my friend and everythings have worked well for 3 months. But now my friend want to stop linode and i need to backup everything back to local machine.
My wp site is just a simple blog. I deployed 3 services by docker-compose which are wordpress, mysql, php_myadmin. Here is my docker-compose.yaml file:
version: "3.0"
services:
mysqlwp:
container_name: mysqlwp
image: mysql:5
environment:
- MYSQL_ROOT_PASSWORD=${PASSWORD}
- MYSQL_DATABASE=${DATABASE}
- MYSQL_USER=${DB_USER}
- MYSQL_PASSWORD=${PASSWORD}
restart: always
#Mount database
volumes:
- '${MYSQL_DATA_DIR}:/var/lib/mysql'
wordpress:
container_name: wordpress
image: wordpress:latest
environment:
- WORDPRESS_DB_NAME=${DATABASE}
- WORDPRESS_DB_USER=${DB_USER}
- WORDPRESS_DB_PASSWORD=${PASSWORD}
ports:
- '80:80'
links:
- 'mysqlwp:mysql'
depends_on:
- 'mysqlwp'
#Mount source code
volumes:
- '${SOURCE_CODE_DIR}:/var/www/html'
restart: always
phpMyAdmin:
container_name: phpMyAdmin
image: phpmyadmin/phpmyadmin
links:
- 'mysqlwp:mysql'
environment:
- PMA_ARBITRARY=1
- PMA_HOST=mysqlwp
depends_on:
- 'mysqlwp'
ports:
- '8888:80'
restart: always
I am not an expert in wordpress and docker, im just learning them forward. I found a ton of plugins of wordpress that help me backup but i am not familiar with them and not sure that what should i pick ?
Should i just backup all the images and database ? How should organize them well for the next relaunch ?
Since you map ${SOURCE_CODE_DIR} to /var/www/html and ${MYSQL_DATA_DIR} to /var/lib/mysql, you should create a backup of the ${SOURCE_CODE_DIR} and ${MYSQL_DATA_DIR} which are stored on the host machine.
It's the whole of your data, other data are temporary and related to the images and docker. If you're looking for creating some backup of the images, you should look for the following topics:
docker save ... command.
docker load ... command.
Related sources:
docker save
docker load
Docker import/export vs. load/save

URL issue in Docker Wordpress site

I wanted to create a local dev environment for a wordpress site using docker.
So I have the following docker-compose file :
version: '3'
services:
db:
image: mariadb
restart: on-failure
environment:
- MYSQL_DATABASE=${WP_DB_NAME}
- MYSQL_USER=${WP_DB_USER}
- MYSQL_PASSWORD=${WP_DB_USER_PASSWORD}
volumes:
#- ./db_data:/var/lib/mysql
- ./mysql_dump/backup.sql:/docker-entrypoint-initdb.d/backup.sql
- ./mysql_dump/migrate.sql:/docker-entrypoint-initdb.d/migrate.sql
networks:
- local
wordpress:
image: wordpress
depends_on:
- db
restart: always
ports:
- 8080:80
environment:
- WORDPRESS_DB_HOST=db
- WORDPRESS_DB_USER=${WP_DB_USER}
- WORDPRESS_DB_PASSWORD=${WP_DB_USER_PASSWORD}
- WORDPRESS_DB_NAME=${WP_DB_NAME}
volumes:
- ./htdocs:/var/www/html
networks:
local:
ipv4_address: 172.23.0.4
networks:
local:
driver: bridge
ipam:
config:
- subnet: 172.23.0.0/24
I use volume to start mariadb with existing database dump.
Website is loading fine, but some URLs are wrong :
When I try to connect, I am redirected to :
http://172.23.0.4/172.23.0.4/wp-admin/ for example
Some js scripts are also not loaded due to wrong URLs like
http://172.23.0.4172.23.0.4/wp-includes/js/tinymce/tinymce.min.js?ver=4920-20181217
I checked the general settings in the admin panel, and the values siteurl and home in the database and they are correct : 172.23.0.4.
The website in production (no docker but classic LAMP install) is working fine by the way…
Do you have any hints ? (I'm not that familiar with web development, especially with wordpress)
Looks like specifying 172.23.0.4 in wordpress settings for home and siteurl is somehow (don't know why though) causing the issue.
Instead, setting the value to http://172.23.0.4 fixed the problem.
If someone has some explanation, please tell me.

How should I set up a development environment with Docker for WordPress themes?

Little disclaimer before I start: I am a Docker newbie.
My question is mostly stated as above, with a little bit more to my requirements:
I want to have a "full" development experience. That is, I want to be able to use VS Code, WebStorm, etc. to do development with full-featured guesser and code intelligence. This is what my current setup is lacking.
I want to have a docker-compose.yml that I can commit into my source repository and not worry about "how it will run" on multiple platforms. I think what I have below accomplishes that, but I am very open to criticism.
docker-compose.yml:
version: '3.1'
services:
wp:
image: wordpress
restart: always
ports:
- 48080:80
links:
- db:mysql
volumes:
- themes:/var/www/html/wp-content/themes
environment:
WORDPRESS_DB_PASSWORD: example
db:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
volumes:
themes:
Any tips for moving forward?
The theme volume did not work on my machine. If I run docker-compose up I get the following error:
This worked for me on Ubuntu 18.04:
version: '3.1'
services:
wp:
image: wordpress
restart: always
ports:
- 48080:80
links:
- db:mysql
volumes:
- ./themes:/var/www/html/wp-content/themes
environment:
WORDPRESS_DB_PASSWORD: example
db:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
Everything else looks quite good, only improvement for now would be hosting your WordPress on your local file system:
That would give you the possibility to debug WordPress easily and you have full control over the stack.
Downside: User permission can be a problem with Docker. Normally every process inside the container will be executed as root. If WordPress writes a file it has root permissions even on you local file system.

Why does closing tutum/wordpress automatically delete all the app and data?

I am new to docker, and trying to run a Wordpress application using this tutum/wordpress image: https://hub.docker.com/r/tutum/wordpress/
I simply follow this step: docker run -d -p 80:80 tutum/wordpress
But when I turn off the computer, and run it again, all the database + application gone. And I need to restart from scratch.
How do I persist the database and application?
That image is deprecated. So you should be using the official wordpress image
version: '3.1'
services:
wordpress:
image: wordpress
ports:
- 8080:80
environment:
WORDPRESS_DB_PASSWORD: example
mysql:
image: mysql:5.7
volumes:
- ./data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: example
Then use docker-compose up to get the wordpress up. The wordpress image has code located at /usr/src/wordpress. So if you need to persist the plugins directory then you need to use volumes to map it like I did for mysql

Resources