Is there any image available that contain wordpress along with mysql data?
Short answer: not recommended.
An image usually deals with one service (so two images would be involved here: wordpress and MySQL)
And the persistent data would not be "in" the image, but on the host in a volume / bind mount.
For instance, the tutumcloud/lamp
image does declare volumes:
# Add volumes for MySQL
VOLUME ["/etc/mysql", "/var/lib/mysql" ]
The docker run
command initializes the newly created volume with any data that exists at the specified location within the base image.
Making your own image without those lines might work as you expect (ie, commit a container with its data).
But if the server reboot at any time, or you have to docker run your original container again, it will start anew, without the data.
A typical docker wordpress image would use a mysql one
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_PASSWORD: example
mysql:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
And in turn, that mysql container would use a local host mounted volume in order to persists the database.
docker run --name some-mysql -v /my/own/datadir:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
See for instance "Quickstart: Compose and WordPress"
So not only should you commit your Wordpress image, but your Mysql one as well, and your volume.
However, committing a volume is not supported: see "Commit content of mounted volumes as well" in order to backup that volume with your WordPress database in it.
With those three backups, you then migrate them to your other server.
However, this seems overly complex, and a fresh WordPress/MySQL docker project on the second server is easier to start.
You would then need, yes, your database dump file.
And some other Wordpress folders (like themes)
See "Easy WordPress Migration with Docker".
That would be the recommended way over trying to commit existing containers form one server and "transplant" them onto another server.