Compose: services.xxx.networks contains {"ExtNet": {"ipv4_address": "192.168.1.11"}}, which is an invalid type, it should be a string

Created on 13 Mar 2017  ·  4Comments  ·  Source: docker/compose

Envionment:

```docker-compose version
docker-compose version 1.11.2, build dfed245
docker-py version: 2.1.0
CPython version: 2.7.5
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013

```uname -srvmpio
Linux 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux```

Scenario:

version: '2.1'

services:
  xxx:
    image: xxx:latest
    networks:
      - ExtNet:
          ipv4_address: 192.168.1.11
      - IntNet

networks:
  ExtNet:
    driver: macvlan
    driver_opts:
      parent: enp3s0
    ipam:
      config:
        - gateway: 192.168.1.1
          ip_range: 192.168.1.10/28
          subnet: 192.168.1.0/24
  IntNet:
    internal: True
    driver: bridge
    ipam:
      config:
        - ip_range: 10.0.0.0/16
          subnet: 10.0.0.0/16

Error:

services.xxx.networks contains {"ExtNet": {"ipv4_address": "192.168.1.11"}}, which is an invalid type, it should be a string

# Tried docker compose yaml version 2.0, 2.1 and 3.0.

Expected:

  • The ability to assign Static IP from ExtNet to xxx docker container in the above example.
kinquestion

Most helpful comment

Actually, that second configuration is incorrect as well. networks is either a list of strings or a mapping (that's YAML's name for python's dict). https://docs.docker.com/compose/compose-file/compose-file-v2/#networks

For example, here's a valid format for your desired config:

services:
  xxx:
    image: xxx:latest
    networks:
      ExtNet:
        ipv4_address: 192.168.1.11
      IntNet: {}

All 4 comments

Update

  • Adding ExtNet by itself to the container seems to be OK:
services:
  xxx:
    image: xxx:latest
    networks:
      - ExtNet:
          ipv4_address: 192.168.1.11

It seems that if one of items in "services.xxx.networks" is a string (in this case, "IntNet"), it expects all of the items to be a string.
Would it be possible to change "services.xxx.networks" to expect tuple?

Actually, that second configuration is incorrect as well. networks is either a list of strings or a mapping (that's YAML's name for python's dict). https://docs.docker.com/compose/compose-file/compose-file-v2/#networks

For example, here's a valid format for your desired config:

services:
  xxx:
    image: xxx:latest
    networks:
      ExtNet:
        ipv4_address: 192.168.1.11
      IntNet: {}

Cool that works. Thank you so much :)

Was this page helpful?
0 / 5 - 0 ratings