Setup Multiple Websites with Docker Further 1

Credits: evertramos

Setting up docker on an old laptop is fun. Especially it provides easy https and reverse proxy.
There are two git repositories that help set this up, but follow them will result not working docker setup.
So I write this down for someone who stuck and for myself.

  1. Follow the instruction on this git: https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion. use the nginx.tmpl from this git.
    the commit I use is this one: dc99e6f85a048be858dbc1e49b24159f35050d6c
    I rename the git folder to nginx-proxy
  2. Follow the instruction on this git: https://github.com/evertramos/wordpress-docker-letsencrypt
    I rename the git folder to www.mydomain.com
    I use root for WordPress, if not WordPress container will restart all the time. Maybe this is fixed in later release of this repository
    WORDPRESS_DB_USER: root
  3. Now you should have WordPress running.
  4. Here is the fun part, let’s try another website, this is our purpose, right?
    Create another folder say helloworld.mydomain.com and cd into it.
  5. nano docker-compose.yml
  6. Fill in with the following content, note: unlike WordPress, I don’t have “VIRTUAL_PORT: 443”, which has been removed while I am writing this.
    version: '3'
    
    services:
       helloworld:
        container_name: helloworld
        image: nginx
        restart: unless-stopped
        expose:
          - "80"
          - "443"
        volumes:
          - /your/path/to/data/:/usr/share/nginx/html
        environment:
          VIRTUAL_HOST: helloworld.mydomain.com
          LETSENCRYPT_HOST: helloworld.mydomain.com
          LETSENCRYPT_EMAIL: email@mydomain.com
    
    networks:
        default:
           external:
             name: webproxy
    
  7.  run cmd
    docker-compose up -d
  8. use browser to browse the new helloworld.

Leave a Reply

Your email address will not be published. Required fields are marked *