2

Hi I need to assign a specific ip for each docker container for my test automation program called sipp.

I cannot ping or telnet to 192.168.173.215

Here is my configration:

version: '3.3'
services:
  sipp4:
    build: 
      context: .
      dockerfile: Dockerfile
    container_name: sipp4
    networks:
        mynetwork:
            ipv4_address: 192.168.128.2
    volumes:
      - ./sipp-3.4.1/:/opt/app/sipp
    environment:
      - "TZ=America/Los_Angeles"
    ulimits:
      nofile:
        soft: 200000
        hard: 400000
    working_dir: /opt/app/sipp
    command: 192.168.173.215:5060 -sf callerCall.xml -inf callerCall.csv -i 192.168.128.2  -aa -m 1 -trace_msg -t un -skip_rlimit -trace_err  
networks:
  mynetwork:
    ipam:
      driver: default
      config:
       - subnet: 192.168.128.0/18
         gateway: 192.168.128.200

I am sure about subnet and gateway because I can assign IP with VMware virtual host.

Here is ifconfig inside docker machine (bash)

ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.128.2  netmask 255.255.192.0  broadcast 192.168.191.255
        ether 02:42:c0:a8:80:02  txqueuelen 0  (Ethernet)
        RX packets 7  bytes 586 (586.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5  bytes 210 (210.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 3  bytes 1728 (1.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3  bytes 1728 (1.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Here is ip

ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
389: eth0@if390: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:c0:a8:80:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.128.2/18 brd 192.168.191.255 scope global eth0
       valid_lft forever preferred_lft forever

on the other hand when I use the configuration below, it can ping and access to 192.168.173.215 and auto assigning IP is: 172.17.0.1

  sipp1:
    build: 
      context: .
      dockerfile: Dockerfile
    container_name: sipp1
    network_mode: host
    volumes:
      - ./sipp-3.4.1/:/opt/app/sipp
    environment:
      - "TZ=America/Los_Angeles"
    ulimits:
      nofile:
        soft: 200000
        hard: 400000
    working_dir: /opt/app/sipp
    command: ./sipp 192.168.173.215:5060 -sf callerCall.xml -inf callerCall.csv -i 172.17.0.1 -aa -m 1 -trace_msg -t un -skip_rlimit -trace_err

When I use the configuration below, its getting ip: 172.18.0.2 and cannot ping anywhere again

  sipp4:
    build: 
      context: .
      dockerfile: Dockerfile
    container_name: sipp4
    volumes:
      - ./sipp-3.4.1/:/opt/app/sipp
    environment:
      - "TZ=America/Los_Angeles"
    ulimits:
      nofile:
        soft: 200000
        hard: 400000
    working_dir: /opt/app/sipp
    command: 192.168.173.215:5060 -sf callerCall.xml -inf callerCall.csv -aa -m 1 -trace_msg -t un -skip_rlimit -trace_err
Software Engineer
  • 15,457
  • 7
  • 74
  • 102
hkn
  • 371
  • 1
  • 14
  • 2
    Why do you need to access it via specific IP?? That is deployment-specific information and best avoided where possible. Why can't you access it via the service name (if in a stack) or on the exposed port on localhost? – JohnXF May 17 '21 at 11:25
  • I need to send 100x audio/video to my server, sipp program sends dummy audio/video to my server, sipp program is also capable for sending multi audio/video to my server but my server accepts only 1 ip so i will run 100xsipp program with 100x different ip's – hkn May 17 '21 at 11:28
  • @hkn I agree with John Fergus -- this is highly unusual and probably not necessary. It seems to be an xy problem. Perhaps you should ask a question relating to your comment, rather than the solution you have come up with. – Software Engineer May 17 '21 at 11:59
  • @SoftwareEngineer i dont have any solution actually, i just want dockers with different ip's that can access my host machine – hkn May 17 '21 at 12:24

0 Answers0