Can't send request from axios in docker container to another container in a same network bridge

Viewed 1204

Can't send request from axios in docker container to another container in a same network bridge .

I created two containers, one custom network and add containers to this network

node js code of test service

const options = {
    method: 'GET',
    url: 'http://172.20.0.1:80/user',
  };
  
  axios.request(options).then(function (response) {
    res.status(200).send(response.data)
  }).catch(function (error) {
    res.status(500).json({"error":error})
  });

Docker compose

authentication:
    container_name: authentication
    build:
      context: ./csp-authentication
    environment: 
      - NODE_SERVER_PORT=80
    ports:
      - "3001:80"
    networks:
      csp_net:
        ipv4_address: 172.20.0.6

test:
    container_name: test
    build:
      context: ./ttt
    ports:
      - "6040:6040"
    networks:
      csp_net:
        ipv4_address: 172.20.0.9
    
networks:
  csp_net:
    name: csp_net
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 172.20.0.0/16
0 Answers
Related