A
A
Alorian2016-11-24 14:51:35
Domain name market
Alorian, 2016-11-24 14:51:35

Docker Windows, how to make your local internet?

I am developing websites. I am using docker as my local web server. When the site has no problems, I write the server config for docker compose, put the site and database files next to the docker-compose.yml file and write them to volume. Then, with one command, the command raises its own local copy of the site at 127.0.0.1 for development and you can work.
I want to use docker as my local internet. That is, get something like openserver, xampp, etc. For example, I have a working site test.ru. I want to raise my local copy of the site at dev.test.ru. I have a site example.com and I want to raise my local copy at dev.example.com. And for these two copies to work as regular sites at the same time.
Yes, you can register ports for each site and manually register domains in hosts with a link to 127.0.0.1. Then open dev.test.ru:8081 or dev.example.com:8082. However, the solution with ports does not seem beautiful to me.
I see only two solutions to the problem
1. Somehow, for each docker-compose.yml, get a static IP address that is visible from the parent windows 10. And already register this static IP address in hosts manually, without a port
2. Use docker swarm mode. As far as I understand, for swarm you can allocate one static IP address, raise it once on the same localhost (127.0.0.1) and then, even without a port, it will address the request to the desired node via the domain.
These two solutions are purely theoretical. In practice, none of them could be implemented. Tell me how exactly (and is it possible at all) to implement one of the two above solutions? Or offer your own so that everything works in much the same way.
There was already a similar question on the toaster , but as a result, no one offered a working solution for docker, they advised vagrant and use a clean virtual machine. However, I'm interested in a working solution specifically for docker.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alorian, 2017-07-26
@Alorian

Finally figured out the problem. I found such a solution for myself:
https://verstaem.com/devops/docker-php-development/
The optimal use case on windows is described in the
"Access to containers through nginx reverse proxy" section
Thanks shaqster . You tried to show the right direction, but you still didn’t fully understand the issue, or I didn’t understand you. In any case, your answers helped a lot in finding the best solution.

Макс, 2016-11-24
@MaxDukov

поставьте на "входе" еще 1 контейнер с nginx, который будет работать как reverse-proxy.

S
shaqster, 2016-11-24
@shaqster

  1. Вам понадобится вот этот контейнер
  2. Примерная конфигурация. Привожу только важное. Возможно вам понадобятся собственные настройки для nginx (мне понадобились).
    version: '2'
    services:
        test:
          expose:
            - "80"
          environment:
            - VIRTUAL_HOST=dev.test.ru
        nginx-proxy:
          image: jwilder/nginx-proxy
          container_name: nginx-proxy
          restart: none
          volumes:
            - /var/run/docker.sock:/tmp/docker.sock:ro
            - ./nginx.conf:/etc/nginx/proxy.conf
          links:
            - test

  3. Необходимо будет настроить сервер в контейнере test на работу с соответствующим доменом
  4. Запускаете, смотрите в какой подсети он поднимается. Добавляете в hosts запись вида 172.19.0.1 dev.test.ru

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question