DOCKER - Installing and running WordPress from a Docker image

I cloned the docker-wordpress-nginx repository on GitHub made by Eugene Ware and built a Docker image from the files in this repository:

$ sudo apt-get install git-core
$ git clone https://github.com/eugeneware/docker-wordpress-nginx.git
$ cd docker-wordpress-nginx
$ sudo docker build -t="docker-wordpress-nginx" .
 

 
These commands run a script that builds an image from the commands in a Dockerfile, which is included in the repository. The resulting image has nginx,  MySQL server, PHP and the WordPress files pre-installed so you can just run it and it will work.

When you run a Docker image, Docker will create a container and run the specified commands in that container. So, the files and processes in this container have no access to the filesystem and processes on the host system.

This also means that by default, the outside world does not have access to the TCP/IP ports in a container. That’s something that you specify yourself. You need to tell Docker which port from the container it needs to expose on the host system.

So, for this blog, I started the container with the following command:
 
$ docker run -d -p 8081:80 docker-wordpress-nginx

This will create a Docker container where port 8081 on the host is routed to port 80 in the container. It will also run the predefined commands in the docker-wordpress-nginx image that will start nginx, MySQL, PHP and WordPress.

Comentarios