I
I
Ivan Pashin2018-01-29 13:00:56
Nginx
Ivan Pashin, 2018-01-29 13:00:56

How to manage multiple versions of an application using docker?

The task is to deploy different application branches in docker containers on a remote server.
Each branch has its own number (task number). The application is deployed using docker-compose and consists of 3 services: nginx, php-fpm, mysql. Each branch should be available under its own url (1001.example.com, 1002.example.com, etc.)
For each branch, I want to run my own nginx, php-fpm and mysql containers
The problem is that nginx port 80 can be connected with server port 80 for only one container, but I want for each.
What is the best way to proceed in this case? How to pass requests to the right container?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ivan Pashin, 2018-02-12
@IvanFantoM

Found a solution to my problem in this article:
Tutorial: Using Docker and Nginx to Host Multiple ...

I
InoMono, 2018-01-29
@InoMono

And how are you even going to distinguish this on the web client side?
If by URL or Header in HTTP, then nginx can handle all this.
Docker Compose is a development tool.
For production, you need to use Docker Swarm or Kubernetes or the like.
They know how. Google "Docker Swarm Blue Green Development"

L
LeoCata, 2018-01-30
@LeoCata

I think you need to look at swarm.
If you really want to run several copies of nginx on the same host, you will have to refuse port forwarding to the host machine:

ports:
            - '80'
            - '443'

Also add a network to each application branch. As a result, we get:
nginx:
        image: nginx:latest
        ports:
            - '80'
            - '443'
        networks:
            - 1001.example.com
        restart: always
networks:
    1001.example.com:
        driver: bridge
        ipam:
            driver: default
            config:
                - subnet: 10.100.0.0/24 #Для каждой ветки своя подсеть.

Then register in /etc/hosts
But it is very crooked and on the knee. I do not recommend repeating.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question