Chapter 2: Introduction to Microservices and Containers
Activity 2: Installing a WordPress Blog and Database Using Docker
Solution:
Perform the following steps to complete this activity:
- Create a folder named
data. This folder will keep the stateful state of the database in the next steps:mkdir data
- Start a MySQL container using the official Docker image and the following specifications:
Use the
datafolder from Step 1 as the database file. Publish port3306to the local system. Set theMYSQL_ROOT_PASSWORDenvironment variable asrootPassword. Set theMYSQL_DATABASEenvironment variable asdatabase. Set theMYSQL_USERenvironment variable asuser. Set theMYSQL_PASSWORDenvironment variable aspassword. Usemysqlas the name of the container. Use themysql:5.7container image:docker run \ -v ${PWD} /data/:/var/lib/mysql \ -p 3306:3306 \ -e MYSQL_ROOT_PASSWORD=rootPassword \ -e MYSQL_DATABASE=database \ -e MYSQL_USER=user \ -e MYSQL_PASSWORD=password \ --name mysql...