0

I have an idea to up several similar instances with my docker-compose simple mini-project.

docker-compose file:

version: '3.1'

services:
 postgres:
   build:
     context: .
     dockerfile: postgres/Dockerfile
   environment:
     - POSTGRES_PASSWORD=postgres
     - POSTGRES_USER=postgres    
   ports:
     - "${PORT_NUMBER}:5432"

Dockerfile:

FROM postgres:9.6

In ./config/.env.dev file I set unique required port number (eg. 5435 for first instance,
5436 for second etc.)

When I up first instance with command:

docker-compose -p instance1 --env-file ./config/.env.dev up

it's OK and I see one new container and one new network instance1_default.

But when I try to up another new instance with command:

docker-compose -p instance2 --env-file ./config/.env.dev up

Docker stuck at this:

Creating network "instance2_default" with the default driver

.. and nothing happens. Yes, I changed port number in env-file before running new instance.

What's wrong with creating new network?

Docker version 20.10.8, build 3967b7d
docker-compose version 1.29.2, build 5becea4c
4

0 回答 0