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
Related
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.
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.
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.
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
I'm trying to setup a drupal 8 installation with docker / docker-compose for local development. What I'd like to have is a local folder that is synchronized with the drupal container's /var/www/html directory, so I could work locally. What is the best way to achieve that?
This is my docker-compose.yml:
mysql:
image: mysql:5.5
ports:
- "3306:3306"
environment:
- MYSQL_USER=xxxxx
- MYSQL_PASSWORD=xxxxxx
- MYSQL_ROOT_PASSWORD=xxxxxxx
- MYSQL_DATABASE=xxxxxxx
drupal:
image: drupal:8.0.4
links:
- mysql
ports:
- "8080:80"
You have to map a folder to your dockerhost. Using docker-compose you would have to add "volumes" to your configuration.
The configuration looks like this (see doc for detailed explanation):
volumes:
- /path/on/your/host:/path/in/your/container
Your configuration would then look like this:
drupal:
image: drupal:8.0.4
volumes:
- /path/on/your/host:/var/www/html
links:
- mysql
cheers,
ceth