Skip to main content
Improving answer details.
Source Link
ivanleoncz
  • 1.9k
  • 7
  • 22
  • 33

Basically, all compose_* containers, are attached to a different Docker Network:, as well as test1, is associated to another network.

$ docker network inspect development_default | grep 'Name\|IPv4' "Name": "development_default", "Name": "compose_postgres", "IPv4Address": "172.20.0.2/16", "Name": "compose_elastic", "IPv4Address": "172.20.0.4/16", "Name": "compose_mongo", "IPv4Address": "172.20.0.3/16", 

These containers were created through Docker Compose, without specifying a custom network. If no custom network is defined on your Docker Compose file, docker will create a custom network which uses the name of the directory from were you have your build environment. That's why the development, name of the directory which was holding the files for generating these containers, was used when creating a network for them.

When executed the command $ docker run --name test1 repo/myapp:stage_1605191501, it was not used the option --network in order to specify the Docker Network development_default, and besides that, test1 would not be able to reach compose_postgres: compose_postgres has 5432 port exposed to the host network and it is also visible for development_default network (172.20.0.0/16), and the Django app which is called on the ENTRYPOINT of test1, is pointing to 0.0.0.0, and not for the IP of compose_postgresthem.

  • When executed the command $ docker run --name test1 repo/myapp:stage_1605191501, no --network was specified, so test1 will be associated to the default bridge network.

  • compose_postgres has 5432 port exposed to the host network and it is associated to development_default network (172.20.0.0/16).

Answer (steps):

  1. provide static IP for compose_postgres
  2. define this IP for the Django app definitions, inside the image of test1, in order to make its connectionprovide connection from the app to compose_postgres database
  3. incorporate thedefine test1development_default toas the development_default--network for (custom network used bytest1 when running compose_postgresdocker run)

For further reference:

Basically, all compose_* containers, are attached to a different Docker Network:

$ docker network inspect development_default | grep 'Name\|IPv4' "Name": "development_default", "Name": "compose_postgres", "IPv4Address": "172.20.0.2/16", "Name": "compose_elastic", "IPv4Address": "172.20.0.4/16", "Name": "compose_mongo", "IPv4Address": "172.20.0.3/16", 

These containers were created through Docker Compose, without specifying a custom network. If no custom network is defined on your Docker Compose file, docker will create a custom network which uses the name of the directory from were you have your build environment. That's why the development, name of the directory which was holding the files for generating these containers, was used when creating a network for them.

When executed the command $ docker run --name test1 repo/myapp:stage_1605191501, it was not used the option --network in order to specify the Docker Network development_default, and besides that, test1 would not be able to reach compose_postgres: compose_postgres has 5432 port exposed to the host network and it is also visible for development_default network (172.20.0.0/16), and the Django app which is called on the ENTRYPOINT of test1, is pointing to 0.0.0.0, and not for the IP of compose_postgres.

Answer (steps):

  1. provide static IP for compose_postgres
  2. define this IP for the Django app, in order to make its connection to compose_postgres
  3. incorporate the test1 to development_default (custom network used by compose_postgres)

For further reference:

Basically, all compose_* containers, are attached to a different Docker Network, as well as test1, is associated to another network.

$ docker network inspect development_default | grep 'Name\|IPv4' "Name": "development_default", "Name": "compose_postgres", "IPv4Address": "172.20.0.2/16", "Name": "compose_elastic", "IPv4Address": "172.20.0.4/16", "Name": "compose_mongo", "IPv4Address": "172.20.0.3/16", 

These containers were created through Docker Compose, without specifying a custom network. If no custom network is defined on your Docker Compose file, docker will create a custom network which uses the name of the directory from were you have your build environment. That's why the development, name of the directory which was holding the files for generating these containers, was used when creating a development_default network for them.

  • When executed the command $ docker run --name test1 repo/myapp:stage_1605191501, no --network was specified, so test1 will be associated to the default bridge network.

  • compose_postgres has 5432 port exposed to the host network and it is associated to development_default network (172.20.0.0/16).

Answer (steps):

  1. provide static IP for compose_postgres
  2. define this IP for the Django app definitions, inside the image of test1, in order to provide connection from the app to compose_postgres database
  3. define development_default as the --network for test1 when running docker run

For further reference:

Source Link
ivanleoncz
  • 1.9k
  • 7
  • 22
  • 33

Basically, all compose_* containers, are attached to a different Docker Network:

$ docker network inspect development_default | grep 'Name\|IPv4' "Name": "development_default", "Name": "compose_postgres", "IPv4Address": "172.20.0.2/16", "Name": "compose_elastic", "IPv4Address": "172.20.0.4/16", "Name": "compose_mongo", "IPv4Address": "172.20.0.3/16", 

These containers were created through Docker Compose, without specifying a custom network. If no custom network is defined on your Docker Compose file, docker will create a custom network which uses the name of the directory from were you have your build environment. That's why the development, name of the directory which was holding the files for generating these containers, was used when creating a network for them.

When executed the command $ docker run --name test1 repo/myapp:stage_1605191501, it was not used the option --network in order to specify the Docker Network development_default, and besides that, test1 would not be able to reach compose_postgres: compose_postgres has 5432 port exposed to the host network and it is also visible for development_default network (172.20.0.0/16), and the Django app which is called on the ENTRYPOINT of test1, is pointing to 0.0.0.0, and not for the IP of compose_postgres.

Answer (steps):

  1. provide static IP for compose_postgres
  2. define this IP for the Django app, in order to make its connection to compose_postgres
  3. incorporate the test1 to development_default (custom network used by compose_postgres)

For further reference: