#Docker #Network #Container

Within your Dockerfile you have to EXPOSE the ports that you want to use e.g. EXPOSE 8080 on NGINX. Afterwards, you can define your own network in the docker-compose.yml file therefore you need to define the network e.g. some-network and provide a subnet range like 172.20.0.0/16. Afterwards you can assign the IPs you would like towards your services in the docker-compose.yml file. As you showed, the network section is already implemented, you just need to adjust it. Firstly change the default name towards your newly defined network name ( some-network ) and as a subsection of that you can add a e,g, ipv4_address: 172.20.0.5. Afterwards this container is reachable under 172.20.0.5:8080. This information can be used as information channel of your application. An example can be found here https://docs.docker.com/compose/networking/

FROM continuumio/miniconda3
...
EXPOSE 8080

docker-compose.yml:

...
nginx:
image: nginx
container_name: "nginx"
build:
context: ..
dockerfile: docker/nginx/Dockerfile
restart: always
networks:
some-network:
ipv4_address: 172.20.0.5
networks:
some-network:
config:
- subnet: 172.20.0.0/16

Configure a Bridge network between Docker container

Currently I try to configure the network between two Docker Container. On the first container my application is running, on the other Container a simple NGINX server is running. I would like to give both a static IP so that I am able to test the communication. The current application and NGINX Dockerfile looks as follows: FROM continuumio/miniconda3 WORKDIR /app COPY ./application /app RUN apt-get update -y && apt-get install -y gcc RUN conda env create -f environment.yml RUN echo "source activate aic_env" > ~/.bashrc ENV PATH /opt/conda/envs/aic_env/bin:$PATH CMD ["python3","src/main.py"] The docker-compose.yml looks like this: version: '3.7' services: application: image: application container_name: "application" build: context: .. dockerfile: docker/application/Dockerfile networks: default nginx: image: nginx container_name: "nginx" build: context: .. dockerfile: docker/nginx/Dockerfile restart: always networks: default What do I need to do for a communication between both containers on a static IP under port 8080 ?
Subscribe to #Docker #Network #Container