Visits: 1139
I would like to containerize my sites, especially this FloatingCloud.io site.
Here are some links that I will use for guidance, wish me luck.
- https://blog.kontena.io/running-your-wordpress-site-in-containers/ – This uses Docker build instead of the official image from Docker Hub
- http://roycornelissen.com/walking-the-talk/
- https://stephenafamo.com/blog/moving-wordpress-docker-container/ – Uses NginX reverse proxy
- https://www.sitepoint.com/how-to-use-the-official-docker-wordpress-image/
- https://stackoverflow.com/questions/45714456/how-to-migrate-docker-volume-between-hosts
- https://docs.docker.com/storage/volumes/#backup-a-container
- https://medium.com/@pybrarian/mysql-databases-that-dont-retain-data-293bc2ed7f02
- https://hub.docker.com/_/wordpress/
- https://www.wpexplorer.com/migrating-wordpress-website/ – uses initdb.d
- create an instance with docker and docker-compose
- copy over the database export with “mysqldump –u[user name] –p[password] [database name] > [dump file] “and a tarZ of the wp-content files
- create dirs to store the wp-content, this will be a docker mounted volume
- create initdb.d dir to be mounted as a volume, put the sql export in there. mysql reads and runs that if it’s DB dir is empty
- edit the docker-compose.yaml file below, you might want to delete the table_prefix if you use the default wp_
- run “docker-compose up” after it work re-run with “docker-compose up -d”
- It takes a while to work, after you get can’t connect to DB errors, the db does magically come up
- account www or apache should be created on the server and ownership of the files should go to it, indeed perhaps create this user in docker group too without root access, for security. I used Ubuntu 19 which comes with user www-data so I just changed the owner to that for www-content, then I was able to update the plugins.
version: '2' services: db: image: mysql:5.7 restart: always ports: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: wordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress volumes: - ./database/data:/var/lib/mysql - ./database/initdb.d:/docker-entrypoint-initdb.d website: image: wordpress:latest working_dir: /var/www/html depends_on: - db ports: - "80:80" volumes: - "/home/steve/wp-content/:/var/www/html/wp-content/" restart: always environment: - WORDPRESS_DB_HOST=db:3306 - WORDPRESS_DB_PASSWORD=wordpress - WP_DEBUG=true - WP_DEBUG_LOG=true - WP_DEBUG_DISPLAY=true - WORDPRESS_TABLE_PREFIX=linuxguru_