0

I'm building my stack of docker container from various docker-compose examples around the net and I constantly run into troubles trying to "convert" between docker-compose file versions.

For this discussion I'm trying to "convert" the QNAP Container station Qnet network driver example [1]:

version: '2'
services:
  qnet_dhcp:
    image: alpine
    command: ifconfig eth0
    networks:
      - qnet-dhcp

  qnet_static:
    image: alpine
    command: ifconfig eth0
    networks:
      qnet-static:
        ipv4_address: 192.168.80.119

networks:
  qnet-dhcp:
    driver: qnet
    ipam:
      driver: qnet
      options:
        iface: "eth0"

  qnet-static:
    driver: qnet
    ipam:
      driver: qnet
      options:
        iface: "eth0"
      config:
        - subnet: 192.168.80.0/23
          gateway: 192.168.80.254

I've come as far as this (the qnet-static section I can't get to work):

version: "3"
services:
  qnet_dhcp:
    image: alpine
    command: ifconfig eth0
    networks:
      - qnet-dhcp

networks:
  qnet-dhcp:
    driver: qnet
    driver_opts:
        iface: "eth0"

This "compiles" but I get errors when I run it (on a QNAP TVS-1282T):

[/share/data/appdata] # docker-compose up -d
Creating network "appdata_qnet-dhcp" with driver "qnet"
Creating appdata_qnet_dhcp_1 ... error

ERROR: for appdata_qnet_dhcp_1  Cannot start service qnet_dhcp: failed to create endpoint appdata_qnet_dhcp_1 owork appdata_qnet-dhcp: NetworkDriver.CreateEndpoint: invalid literal for int() with base 16: ''

ERROR: for qnet_dhcp  Cannot start service qnet_dhcp: failed to create endpoint appdata_qnet_dhcp_1 on network ta_qnet-dhcp: NetworkDriver.CreateEndpoint: invalid literal for int() with base 16: ''
ERROR: Encountered errors while bringing up the project.

Can someone clarify the changes between docker-compose file version 2 and version 3 that are relevant to this example?

[1] https://qnap-dev.github.io/container-station-api/qnet.html#docker-compose

2 Answers2

0

I had a similar problem, for the time being, I've used the following workaround.

  1. I manually create the network:

    docker network create -d qnet --ipam-driver=qnet --ipam-opt=iface=bond0 qnet-dhcp

  2. Then use it in my docker-compose file like this:

networks: qnet-dhcp: external: name: qnet-dhcp

tenfourty
  • 2,111
  • 1
  • 13
  • 5
0

I solved this by just using version: '2.4' for the docker-compose.yml:

version: "2.4"
services:
  qnet_dhcp:
    image: alpine
    command: ifconfig eth0
    mac_address: 02:42:ac:11:65:43 # you can even set a mac address!
    mem_limit: 512000000 # memory limit to 512mb
    cpus: 0.5
    networks:
      - qnet-dhcp

networks:
  qnet-dhcp:
    driver: qnet
    ipam:
      driver: qnet
      options:
        iface: "eth0"

Most of the time it is easy to adapt version "3" back to version "2.4". And it works perfectly on my QNAP. And with setting the mac address my fritz box gives the container always the same ip address.

illnr
  • 750
  • 9
  • 13