Create a Website using Docker

Setting up a website from docker is easier than you might think! This guide will show you how to create a website that also supports PHP.

Step 1

The first step is to install docker. Please see my guide on how to install here.

Step 2

Once you have docker installed, we can start with building the base website. The following is a docker-compose.yml contents that will help you get started and build the site from scratch. I recommend building this within Dockge

This will start the webserver on Port 80. If using Dockge, the HTML files will be located in /opt/stacks/website/data/html. The NGINX Config will be hosted at /opt/stacks/website/data/nginx.conf. The PHP config will be hosted at /opt/stacks/website/data/www.conf.

Change the urls at the bottom to align with what you need.

version: "3.3"
services:
  website:
    ports:
      - 80:8080
    volumes:
      - ./data/html:/var/www/html
      - ./data/nginx.conf:/etc/nginx/nginx.conf
      - ./data/www.conf:/etc/php82/php-fpm.d/www.conf
    image: erseco/alpine-php-webserver
    restart: unless-stopped
x-dockge:
  urls:
    - https://weburl.com
    - http://ipaddress:80
networks: {}

Step 3

When you first start the container, it will most likely fail to start until we add the nginx.conf and the www.conf to the directory. I use WinSCP to SSH into the server and modify the directories. I have included downloads to both the nginx.conf and www.conf. Copy both of these files to the /opt/stacks/website/data folder.

Step 4

Start the container in Dockge, and it should start properly now.

Your website will be on http://ipaddress:80

Back to Docker Guides

Creating a Website from Docker using NGINX | Wells Systems