There are many tutorials for creating new WordPress sites with Docker containers such as this one, however there aren’t many for those who already have a site and want to migrate existing WordPress installations to Docker containers.
│ ├── conf.d
│ ├── h5bp
│ ├── sites-available
│ ├── sites-enabled
│ └── ssl
│ └── 7.0
│ └── src
│ └── src
Use official Docker Installation or use the code below to install since the version in the standard repo’s are dated.
wget -qO- https://get.docker.com/ | sh #or sudo curl -fsSL get.docker.com | sh
First step is to backup your MySQL database and Tar your WordPress wp-content directory. Unlike most DB backup tutorials, this creates the database if it does not exist with the -B switch. My WordPress Docker image (wp_img) contains the rest of the files of the latest version. This site will help if you don’t have the ability to create a backup but do have the database files.
#Backup wordpress db mysqldump -u [user] -p -B -h [hostname] [database] --triggers --routines > ~/wordpress.sql #Backup wp-content tar -cvzf ~/wp-content.tar.gz /var/www/html/wp-content #Or backup entire site directory tar -cvzf ~/wp-full.tar.gz /var/www/html
FROM mariadb:10.0 ADD *.sql /docker-entrypoint-initdb.d/ ADD *.sh /docker-entrypoint-initdb.d/
The official MariaDB/MySQL Docker images will execute .sh, .sql and .sql.gz files in the containers /docker-entrypoint-initdb.d directory, which contains the wordpress.sql backup file along with any shell scripts.
docker build . -t sysinfo-io:mariadb10.0 docker run -d -e MYSQL_RANDOM_ROOT_PASSWORD=yes -p 3306:3306 -v /docker/wp_db/var:/var/lib/mysql -v /docker/wp_db/etc:/etc/mysql/conf.d --name wp_db -t sysinfo-io:mariadb10.0
When you're a little too careless about virtualizing your domain controllers, cloning, migrating, backing up and restoring, returning from vacation… Read More
Systemd is new service manager for Linux. It's a replacement for all previous init systems (SysV/SysVinit & Ubuntu's Upstart) and… Read More