S
S
springrain10102019-03-04 00:19:07
Docker
springrain1010, 2019-03-04 00:19:07

Docker-compose, Windows 10: multiple local sites?

Hello!
I'm trying to set up a local development environment (LAMP), figuring out Docker.
All sites I have are in the Sites folder with the following structure:

/Sites
  -- site1.local
     -- www
  -- site2.local
     -- www

Each site needs its own version of PHP, MySQL, and so on.
It turned out to write such a docker-compose and launch 1 site (php: 7.1-apache is used):
version: "3"

services:
  webserver:
    build: 
      context: ./bin/webserver
    container_name: 'sp-webserver'
    restart: 'always'
    ports:
      - "80:80"
      - "443:443"
    links: 
      - mysql
    volumes: 
      - ${DOCUMENT_ROOT-./www}:/var/www/html
      - ${PHP_INI-./config/php/php.ini}:/usr/local/etc/php/php.ini
      - ${VHOSTS_DIR-./config/vhosts}:/etc/apache2/sites-enabled
      - ${LOG_DIR-./logs/apache2}:/var/log/apache2
  mysql:
    build: ./bin/mysql
    container_name: 'sp-mysql'
    restart: 'always'
    ports:
      - "3306:3306"
    volumes: 
      - ${MYSQL_DATA_DIR-./data/mysql}:/var/lib/mysql
      - ${MYSQL_LOG_DIR-./logs/mysql}:/var/log/mysql
    environment:
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: sp-demo
      MYSQL_USER: sp-demo
      MYSQL_PASSWORD: sp-demo
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: 'rb-phpmyadmin'
    links:
      - mysql
    environment:
      PMA_HOST: mysql
      PMA_PORT: 3306
    ports:
      - '8080:80'
    volumes: 
      - /sessions
  redis:
    container_name: 'rb-redis'
    image: redis:latest
    ports:
      - "6379:6379"

The site is available at http://localhost:80
Questions:
1) How to access the site via the local domain? For example, site1.local instead of http://localhost:80. I heard about https://github.com/jwilder/nginx-proxy, but I don't understand how to set it up with Apache in this case.
2) How can I do the same for the second site (site2.local) to run them at the same time? I understand that you will need to change ports (80, 443 and 3306), otherwise there will be a conflict with docker-compose up -d? Is it possible to do this without changing ports?
Thanks for answers!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Shumov, 2019-03-04
@inoise

Each site has its own container and another one next to it purely for a web server that sends traffic to one or another backend by name

N
Nikita Krasnikov, 2019-03-04
@YekitKsv

You can allocate a separate network and register domain names in the host machine in the /etc/hosts file.
Configuration example: https://github.com/YekitKsv/docker-templates

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question