github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/g3doc/user_guide/tutorials/docker.md (about) 1 # WordPress with Docker 2 3 This page shows you how to deploy a sample [WordPress][wordpress] site using 4 [Docker][docker]. 5 6 ### Before you begin 7 8 [Follow these instructions][docker-install] to install runsc with Docker. This 9 document assumes that the runtime name chosen is `runsc`. 10 11 ### Running WordPress 12 13 Now, let's deploy a WordPress site using Docker. WordPress site requires two 14 containers: web server in the frontend, MySQL database in the backend. 15 16 First, let's define a few environment variables that are shared between both 17 containers: 18 19 ```bash 20 export MYSQL_PASSWORD=${YOUR_SECRET_PASSWORD_HERE?} 21 export MYSQL_DB=wordpress 22 export MYSQL_USER=wordpress 23 ``` 24 25 Next, let's start the database container running MySQL and wait until the 26 database is initialized: 27 28 ```bash 29 docker run --runtime=runsc --name mysql -d \ 30 -e MYSQL_RANDOM_ROOT_PASSWORD=1 \ 31 -e MYSQL_PASSWORD="${MYSQL_PASSWORD}" \ 32 -e MYSQL_DATABASE="${MYSQL_DB}" \ 33 -e MYSQL_USER="${MYSQL_USER}" \ 34 mysql:5.7 35 36 # Wait until this message appears in the log. 37 docker logs mysql |& grep 'port: 3306 MySQL Community Server (GPL)' 38 ``` 39 40 Once the database is running, you can start the WordPress frontend. We use the 41 `--link` option to connect the frontend to the database, and expose the 42 WordPress to port 8080 on the localhost. 43 44 ```bash 45 docker run --runtime=runsc --name wordpress -d \ 46 --link mysql:mysql \ 47 -p 8080:80 \ 48 -e WORDPRESS_DB_HOST=mysql \ 49 -e WORDPRESS_DB_USER="${MYSQL_USER}" \ 50 -e WORDPRESS_DB_PASSWORD="${MYSQL_PASSWORD}" \ 51 -e WORDPRESS_DB_NAME="${MYSQL_DB}" \ 52 -e WORDPRESS_TABLE_PREFIX=wp_ \ 53 wordpress 54 ``` 55 56 Now, you can access the WordPress website pointing your favorite browser to 57 <http://localhost:8080>. 58 59 Congratulations! You have just deployed a WordPress site using Docker. 60 61 ### What's next 62 63 Learn how to deploy WordPress with [Kubernetes][wordpress-k8s] or 64 [Docker Compose][wordpress-compose]. 65 66 [docker]: https://www.docker.com/ 67 [docker-install]: ../quick_start/docker.md 68 [wordpress]: https://wordpress.com/ 69 [wordpress-k8s]: kubernetes.md 70 [wordpress-compose]: docker-compose.md