Answer the question
In order to leave comments, you need to log in
Docker+nodejs+5ip. How to make external http request through different IPs?
1) There is a third-party api with a limit on the number of requests per minute.
2) There is a dedicated server with 5 ip addresses.
3) Application on nodejs + docker
The task is to run 5 containers so that each http request is made through its own ip address. In order not to run into limits
Answer the question
In order to leave comments, you need to log in
https://www.npmjs.com/package/request#requestoptio...
localAddress
use the macvlan driver https://docs.docker.com/network/macvlan/
like this:
docker network create -d macvlan --subnet=10.2.4.96/16 --gateway=10.1.1.1 -o parent=eno1 mac_net
docker run --net=mac_net --ip=10.2.5.5 -it --rm busybox
/ # ping 10.1.2.10 -c 1
PING 10.1.2.10 (10.1.2.10): 56 data bytes
64 bytes from 10.1.2.10: seq=0 ttl=63 time=0.423 ms
docker run --net=mac_net --ip=10.2.5.6 -it --rm busybox
/ # ping 10.1.2.10 -c 1
PING 10.1.2.10 (10.1.2.10): 56 data bytes
64 bytes from 10.1.2.10: seq=0 ttl=63 time=0.423 ms
10:29:07.257561 IP 10.2.5.5 > 10.1.2.10: ICMP echo request, id 1536, seq 2, length 64
10:29:07.257924 IP 10.1.2.10 > 10.2.5.5: ICMP echo reply, id 1536, seq 2, length 64
10:29:26.101902 IP 10.2.5.6 > 10.1.2.10: ICMP echo request, id 1536, seq 0, length 64
10:29:26.102431 IP 10.1.2.10 > 10.2.5.6: ICMP echo reply, id 1536, seq 0, length 64
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question