Docker Community Forums

Share and learn in the Docker community.

Assigning static ips to docker containers

docker

(Ashsek) #1

I am trying to assign IP addresses to Docker containers by framing my compose file as :
version: ‘2’

volumes:
  orderer.example.com:
  peer0.org1.example.com:
  peer1.org1.example.com:
  peer0.org2.example.com:
  peer1.org2.example.com:

networks:
  byfn:
    driver: bridge
    driver_opts:
      com.docker.network.enable_ipv6: "false"
    ipam:
      driver: default
      config:
      - subnet: 192.168.43.0/24
        gateway: 192.168.43.1

services:

  orderer.example.com:
    extends:
      file:   base/docker-compose-base.yaml
      service: orderer.example.com
    container_name: orderer.example.com
    networks:
      byfn:
        ipv4_address: 192.168.43.10

  peer0.org1.example.com:
    container_name: peer0.org1.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer0.org1.example.com
    networks:
      byfn:
        ipv4_address: 192.168.43.2

but it is throwing the following error:

 services.peer1.org1.example.com.networks.ipv4_address contains an invalid type, it should be an object, or a null