To start:
$ docker run --rm -d --name my-mysql -e MYSQL_ROOT_PASSWORD=passwd mysql
$ docker run --rm -d --name my-wordpress --link my-mysql:mysql -p 80:80 wordpressThen open http://localhost. It might take a minute to connect to the server successfully.
To stop:
$ docker stop my-mysql my-wordpressYou can change following values.
my-mysql... Name of the MySQL container.my-wordpress... Name of the WordPress container.passwd... Password for the MySQL DB.80... Port to access the WP site. It can be like8080:80to access viahttp://localhost:8080.
Add -v or --volume options.
$ docker run --rm -d --name my-mysql -e MYSQL_ROOT_PASSWORD=passwd -v `pwd`/db:/var/lib/mysql mysql
$ docker run --rm -d --name my-wordpress --link my-mysql:mysql -p 80:80 -v `pwd`/wp:/var/www/html wordpressThen keep directories db and wp.
If you prefer Windows, replace pwd and surrounding back quotes with %CD%.
Note: Remember you have to specify local directories in FULL PATH. ./db doesn't work.
You have to set the following variable to MySQL using -e or --env.
MYSQL_ROOT_PASSWORD
For WordPress, there are some environments you can set if you want. Find them at the documentation.
There are lots of variations sets for a container.
For example:
4.8.3-php7.1-fpm-alpine4.8.2-php5.6-apachecli-1.4.0-php7.1
Check the documentation for full information.
A tag cli and its variations provide you CLI tool.
Use --volumes-from and --link options to access your WordPress environment and drive them through the tool.
$ docker run --rm -ti --volumes-from my-wordpress --link my-mysql:mysql wordpress:cli plugin list
+---------+----------+-----------+---------+
| name | status | update | version |
+---------+----------+-----------+---------+
| akismet | inactive | available | 4.0 |
| hello | inactive | none | 1.6 |
+---------+----------+-----------+---------+