Docker Community Forums

Share and learn in the Docker community.

Make WordPress Docker image available on local network (Linux Mint)

Hi, I am completely new to Docker and I am not a dev, but a tech marketer.
I managed to set up docker and get a WordPress site up and running on my Linux Mint machine.
Now I want to be able to access the WordPress website from a windows machine on the same network.

It is clear to me that this question has been asked hundreds of time, but all those forum posts talk about doing it on Windows or Mac. Also, these posts assume you have a better understanding of network management + docker in general.

So what I am basically looking for is a beginner guide / the exact steps to take on Linux Mint or in Docker to make the site available on my local network for other machines.

Thanks for tips.
rolf

First, visit the Docker homepage and look for the Get Docker tab. Then, choose the version you want based on your operating system:

Downloading Docker.
On the next page, you can download the application and then run the installer. This part is very simple – all you need to do is keep moving through the screens and wait until the installation is complete. When it’s done, you’ll need to restart your computer.

Once your system is back up and running, open your command line. On Windows, you can just search for Powershell if you don’t want to install another program. Then, type in docker ps. If you installed Docker successfully, you should see something like this:

A list of your running Docker containers.
That’s a list of the containers currently running on your computer and as you can see, it’s empty. Let’s fix that right away.

Step #2: Set up a container with a WordPress environment
There are two ways to go about this step – you can create a container and set up all the elements you need one by one, or you can do it all in one fell swoop. Naturally, the second route is the smart way to go, so let’s walk through it.

We’re going to use a tool called Docker Compose, which enables you to configure the services you want your container to have and set them up all at once. Start out by opening the command line again and entering these two commands, one after the other:

mkdir wordpress-local && cd wordpress-local
touch docker-compose.yml
What these commands do is create a directory called wordpress-local on your computer, then add a new file called docker-compose.yml inside that directory.

In order to create your WordPress environment, you’ll need to add some parameters to that file. Using your normal folder tool, find the folder you just created on your computer and open docker-compose.yml using your favorite text editor. Paste the following code snippet into the file:

web:
image: wordpress
links:

  • mysql
    environment:
  • WORDPRESS_DB_PASSWORD=password
    ports:
  • “127.0.0.3:8080:80”
    mysql:
    image: mysql:5.7
    environment:
  • MYSQL_ROOT_PASSWORD=password
  • MYSQL_DATABASE=my-wpdb
    Save your changes now, and close your editor. What you just did is instruct Docker to set up a new database for WordPress (called my-wpdb) and install the platform itself along with all the other services it needs. We also assigned specific ports and individual passwords, which you can customize by editing the values in the file. With that out of the way, let’s move on to the last step.

Step #3: Get your WordPress container up and running
All that’s left now is to tell Docker to start up your container. To do that, use the following command from within the folder where your docker-compose.yml is located.

docker-compose up -d
Now, sit back and wait for Docker to download and set up all the services you indicated in your docker-compose.yml file. This might take a few minutes, depending on your internet connection.

Once the setup is complete, you’ll be able to access your WordPress site from any browser by entering the ports you set up earlier. In this case, those would be 127.0.0.3:8080:

Local WordPress development using Docker: Finishing up.
All that’s left to do now is follow the regular WordPress setup process in your browser.

Keep in mind that you can set up as many Docker containers as you want, and power them up or down at will using these two commands:

docker-compose stop
docker-compose up -d

Thanks, but setting up is not the issue. I have my Wordpress site up and running with docker.
I want to make the site available on local network, see my initial post.