How to install WordPress with Docker


Image: Jack Wallen Docker is an exceptionally powerful and versatile tool that permits you to provide containerized applications such that they are encapsulated and a lot easier to release. I wish to show how simple this is by setting up WordPress by means of Docker.

Let’s get to the installation.Install and setup the database container Since WordPress relies upon a database,

we’ll set up MariaDB by means of Docker and then produce the needed database. The very first thing that should be done is to open up a terminal window and pull the current MariaDB container with the command: sudo docker pull mariadb As soon as the container has actually been effectively pulled, you must initially produce a couple of directory sites to house the WordPress data. This is done with the following commands (we’ll create the directory site in/ opt ). sudo mkdir/ opt/wordpress. sudo mkdir- p/ opt/wordpress/database. sudo mkdir- p/ opt/wordpress/html Next we create the MariaDB

container with the command: docker run -e MYSQL_ROOT_PASSWORD= XXX -e MYSQL_USER= wpuser- e MYSQL_PASSWORD= XXX -e MYSQL_DATABASE= wordpress_db -v/ opt/wordpress/database:/ var/lib/mysql-- name wordpressdb -d mariadb Where XXX are strong passwords to be utilized for the MySQL root user and the MySQL wpuser account.The above command will develop

the wpuser account and develop the WordPress database, wordpress_db Next we need to learn what IP address is related to our brand-new container. Provide the command: docker examine- f’ ‘wordpressdb The command will respond with the IP address for your container (Figure A

).< img src= alt =" Figure A" > Discovering the IP address of your MariaDB dockercontainer.You can now

Figure A

connect to MySQL on that address with the command: mysql- u wpuser

- h IP_ADDRESS -p Where IP_ADDRESS is the actual address for the container. You'll be triggered for the password you developed for the wpuser; go into that and the MySQL prompt will appear. Exit out of that prompt by typing exit; and you're ready to move on.Install WordPress Now we should pull down the latest variation of WordPress. This is finished with the following command: docker pull wordpress: most current Allow that pull to complete and then develop the new container with the command: docker run -e WORDPRESS_DB_USER =wpuser- e WORDPRESS_DB_PASSWORD

= XXX- e WORDPRESS_DB_NAME= wordpress_db- p 8081:80- v/ opt/wordpress/html:/ var/www/html-- link wordpressdb: mysql-- name wpcontainer- d wordpress Where XXX is the password for the wpuser you developed earlier.At this point you can now point an internet browser to http://SERVER_IP:8081 and begin the basic WordPress installation. Where SERVER_IP is the IP address of the server hosting docker, not the container address. Congratulations, you have actually simply

released your WordPress container.The simplicity of containers As you can see, containers are really rather easy to deploy( even with the included intricacy of needing to link with a database server ). With a couple of commands you can have a containerized WordPress deployment up and running, thanks to Docker.Also see< div

data-modal-options =' ' > Jack Wallen is an acclaimed writer for TechRepublic and He's a devoted promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his site


Written by 

Related posts