Docker Community Forums

Share and learn in the Docker community.

Setting Up MACVLAN in Compose


(Jap42) #1

I am trying to install hub.docker.com/r/tiredofit/freepbx using compose. I updated to the latest version

docker-compose version 1.23.2, build 1110ad01
docker-py version: 3.6.0
CPython version: 3.6.7
OpenSSL version: OpenSSL 1.1.0f  25 May 2017

The sample compose works. However I want to use the MACVLAN driver to give the container its own IP on the network. This makes it easier to setup IP phones without remapping a bunch of ports to not conflict with other services. I have the network created already. 1bdcc23db71c macvlan macvlan local It looks like this should be it:

networks:
    -macvlan

The older version seemed to look like

networks:
  macvlan:
    external: true

I can not get anything to work. First one gives me: services.freepbx-app.networks contains an invalid type, it should be an array, or an object the second says external is not a valid option.

Any ideas?

version: '2'

services:
  freepbx-app:
    container_name: freepbx-app
    image: tiredofit/freepbx
    volumes:
      - ./certs:/certs
      - ./data:/data
      - ./logs:/var/log
      - ./data/www:/var/www/html
      - ./db:/var/lib/mysql
      - ./assets/custom:/assets/custom

    environment:
      - ZABBIX_HOSTNAME=freepbx-app
      - RTP_START=18000
      - RTP_FINISH=18100
      - DB_EMBEDDED=TRUE
    restart: always
    cap_add:
      - NET_ADMIN
    privileged: true

    networks:
      -macvlan

(Martin Terp) #2

Hi :slight_smile:

You have told that the freebpx-app should be a member of the “macvlan” network, but you have not defined the macvlan network (maybe use another name for it to avoid confusion)

So, you need to define, what kind of network, macvlan is.
Like:

version: '2'

  services:
    freepbx-app:
      container_name: freepbx-app
      image: tiredofit/freepbx
      volumes:
        - ./certs:/certs
        - ./data:/data
        - ./logs:/var/log
        - ./data/www:/var/www/html
        - ./db:/var/lib/mysql
        - ./assets/custom:/assets/custom

      environment:
        - ZABBIX_HOSTNAME=freepbx-app
        - RTP_START=18000
        - RTP_FINISH=18100
        - DB_EMBEDDED=TRUE
      restart: always
        cap_add:
          - NET_ADMIN
      privileged: true
      networks:
        - macvlan

  networks:
    macvlan:
      external: true