Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

librenms docker-compose.yml doesn't work on Windows (10) #45

Closed
xorr0 opened this issue Nov 15, 2019 · 2 comments
Closed

librenms docker-compose.yml doesn't work on Windows (10) #45

xorr0 opened this issue Nov 15, 2019 · 2 comments

Comments

@xorr0
Copy link

xorr0 commented Nov 15, 2019

The default docker-compose.yml in the examples folder does NOT work on Windows (10). When running docker-compose up it errors out for every volume specification in the docker-compose.yml file with Cannot create container for service ${SERVICE_NAME}: invalid volume specification
Here's just one of the errors, it happens with all of the "volume" configs in the docker-compose.yml file:

ERROR: for librenms_rrdcached  Cannot create container for service rrdcached: invalid volume specification: 'H:\devel\librenms-docker\examples\compose\rrd-journal:/data/journal:rw'

Looks like we have to set this in our ~/Documents/WindowsPowershell/Microsoft.PowerShell_profile.ps1
...
$Env:COMPOSE_CONVERT_WINDOWS_PATHS=1
...

  1. Follow the above instruction to set the environment variable COMPOSE_CONVERT_WINDOWS_PATHS=1 in the specified Microsoft.Powershell_profile.ps1 script
  2. Modify the default docker-compose.yml in the librenms-docker examples folder, the following worked perfectly for me (note: I added the ports section to each service container so I could easily modify the published (windows host) port, it had no adverse affect by leaving the port specifications there. Ultimately, it's just more verbose):
version: "3.5"

services:
  db:
    image: mariadb:10.2
    container_name: librenms_db
    command:
      - "mysqld"
      - "--sql-mode="
      - "--innodb-file-per-table=1"
      - "--lower-case-table-names=0"
      - "--character-set-server=utf8"
      - "--collation-server=utf8_unicode_ci"
    ports:
      - target: 3306
        published: 3306
        protocol: tcp
    volumes:
      ## ORIGINAL
      #- "./db:/var/lib/mysql"
      ##
      - db-mysql-volume:/var/lib/mysql:Z
    environment:
      - "TZ=${TZ}"
      - "MYSQL_ALLOW_EMPTY_PASSWORD=yes"
      - "MYSQL_DATABASE=${MYSQL_DATABASE}"
      - "MYSQL_USER=${MYSQL_USER}"
      - "MYSQL_PASSWORD=${MYSQL_PASSWORD}"
    restart: always

  memcached:
    image: memcached:alpine
    container_name: librenms_memcached
    ports:
      - target: 11211
        published: 11211
        protocol: tcp
    environment:
      - "TZ=${TZ}"
    restart: always

  rrdcached:
    image: crazymax/rrdcached
    container_name: librenms_rrdcached
    ports:
      - target: 42217
        published: 42217
        protocol: tcp
    volumes:
      ## ORIGINAL
      #- "./librenms/rrd:/data/db"
      #- "./rrd-journal:/data/journal"
      ##
      - rrd-librenms-volume:/data/db:Z
      - rrd-journal-volume:/data/journal:Z
    environment:
      - "TZ=${TZ}"
      - "LOG_LEVEL=LOG_INFO"
      - "WRITE_TIMEOUT=1800"
      - "WRITE_JITTER=1800"
      - "WRITE_THREADS=4"
      - "FLUSH_DEAD_DATA_INTERVAL=3600"
    restart: always

  smtp:
    image: juanluisbaptiste/postfix
    container_name: librenms_smtp
    #volumes:
      ## ORIGINAL
      #- "/etc/localtime:/etc/localtime:ro"
      ## *NEITHER WORKED*
      #- smtp-localtime-volume:/etc/localtime:ro
      #- smtp-etc-localtime-volume:/etc/localtime:Z
      ## *ALWAYS GETTING ERROR*
      # ERROR: for smtp  Cannot create container for service smtp: source is not directory
      ## I believe it's because this folder doesn't even exist, it's a RO share ultimately
      ## since on Windows /etc/localtime doesn't exist, hence the error.
      ## By taking the volume out entirely, it works!
      ##
    environment:
      - "SERVER_HOSTNAME=librenms.example.com"
      - "SMTP_SERVER=${SMTP_SERVER}"
      - "SMTP_USERNAME=${SMTP_USERNAME}"
      - "SMTP_PASSWORD=${SMTP_PASSWORD}"
    restart: always

  librenms:
    image: librenms/librenms:latest
    container_name: librenms
    domainname: example.com
    hostname: librenms
    ports:
      - target: 80
        published: 80
        protocol: tcp
    depends_on:
      - db
      - memcached
      - rrdcached
      - smtp
    volumes:
      ## ORIGINAL
      #- "./librenms:/data"
      ##
      - lnms-data-volume:/data:Z
    environment:
      - "TZ=${TZ}"
      - "PUID=${PUID}"
      - "PGID=${PGID}"
      - "DB_HOST=db"
      - "DB_NAME=${MYSQL_DATABASE}"
      - "DB_USER=${MYSQL_USER}"
      - "DB_PASSWORD=${MYSQL_PASSWORD}"
      - "DB_TIMEOUT=30"
    env_file:
      - "./librenms.env"
    restart: always

  cron:
    image: librenms/librenms:latest
    container_name: librenms_cron
    domainname: example.com
    hostname: librenms
    depends_on:
      - librenms
    volumes:
      ## ORIGINAL
      #- "./librenms:/data"
      ##
      - lnms-data-volume:/data:Z
    environment:
      - "TZ=${TZ}"
      - "PUID=${PUID}"
      - "PGID=${PGID}"
      - "DB_HOST=db"
      - "DB_NAME=${MYSQL_DATABASE}"
      - "DB_USER=${MYSQL_USER}"
      - "DB_PASSWORD=${MYSQL_PASSWORD}"
      - "DB_TIMEOUT=30"
      - "SIDECAR_CRON=1"
    env_file:
      - "./librenms.env"
    restart: always

  syslog-ng:
    image: librenms/librenms:latest
    container_name: librenms_syslog
    domainname: example.com
    hostname: librenms
    depends_on:
      - librenms
    ports:
      - target: 514
        published: 514
        protocol: tcp
      - target: 514
        published: 514
        protocol: udp
    volumes:
      ## ORIGINAL
      #- "./librenms:/data"
      ##
      - lnms-data-volume:/data:Z
    environment:
      - "TZ=${TZ}"
      - "PUID=${PUID}"
      - "PGID=${PGID}"
      - "DB_HOST=db"
      - "DB_NAME=${MYSQL_DATABASE}"
      - "DB_USER=${MYSQL_USER}"
      - "DB_PASSWORD=${MYSQL_PASSWORD}"
      - "DB_TIMEOUT=30"
      - "SIDECAR_SYSLOGNG=1"
    env_file:
      - "./librenms.env"
    restart: always

volumes:
  db-mysql-volume:
    external: false
  rrd-librenms-volume:
    external: false
  rrd-journal-volume:
    external: false
  lnms-data-volume:
    external: false
@crazy-max
Copy link
Member

@xorr0 I don't provide support for Windows for this Docker image but thank you for your report. I think this will help Windows users.

@FurmanSK
Copy link

The default docker-compose.yml in the examples folder does NOT work on Windows (10). When running docker-compose up it errors out for every volume specification in the docker-compose.yml file with Cannot create container for service ${SERVICE_NAME}: invalid volume specification
Here's just one of the errors, it happens with all of the "volume" configs in the docker-compose.yml file:

ERROR: for librenms_rrdcached  Cannot create container for service rrdcached: invalid volume specification: 'H:\devel\librenms-docker\examples\compose\rrd-journal:/data/journal:rw'
* I ran into this exact same issue with another project, and [filed an issue](https://github.com/netdisco/netdisco-docker/issues/25)

* The FIX is two-fold, as reported in the [docker-compose issues #4240](https://github.com/docker/compose/issues/4240#issuecomment-267746348):

Looks like we have to set this in our ~/Documents/WindowsPowershell/Microsoft.PowerShell_profile.ps1
...
$Env:COMPOSE_CONVERT_WINDOWS_PATHS=1
...

1. Follow the above instruction to set the environment variable `COMPOSE_CONVERT_WINDOWS_PATHS=1` in the specified `Microsoft.Powershell_profile.ps1` script

2. Modify the default `docker-compose.yml` in the librenms-docker `examples` folder, the following worked perfectly for me (note: I added the `ports` section to each service container so I could easily modify the published (windows host) port, it had no adverse affect by leaving the port specifications there. Ultimately, it's just more verbose):
version: "3.5"

services:
  db:
    image: mariadb:10.2
    container_name: librenms_db
    command:
      - "mysqld"
      - "--sql-mode="
      - "--innodb-file-per-table=1"
      - "--lower-case-table-names=0"
      - "--character-set-server=utf8"
      - "--collation-server=utf8_unicode_ci"
    ports:
      - target: 3306
        published: 3306
        protocol: tcp
    volumes:
      ## ORIGINAL
      #- "./db:/var/lib/mysql"
      ##
      - db-mysql-volume:/var/lib/mysql:Z
    environment:
      - "TZ=${TZ}"
      - "MYSQL_ALLOW_EMPTY_PASSWORD=yes"
      - "MYSQL_DATABASE=${MYSQL_DATABASE}"
      - "MYSQL_USER=${MYSQL_USER}"
      - "MYSQL_PASSWORD=${MYSQL_PASSWORD}"
    restart: always

  memcached:
    image: memcached:alpine
    container_name: librenms_memcached
    ports:
      - target: 11211
        published: 11211
        protocol: tcp
    environment:
      - "TZ=${TZ}"
    restart: always

  rrdcached:
    image: crazymax/rrdcached
    container_name: librenms_rrdcached
    ports:
      - target: 42217
        published: 42217
        protocol: tcp
    volumes:
      ## ORIGINAL
      #- "./librenms/rrd:/data/db"
      #- "./rrd-journal:/data/journal"
      ##
      - rrd-librenms-volume:/data/db:Z
      - rrd-journal-volume:/data/journal:Z
    environment:
      - "TZ=${TZ}"
      - "LOG_LEVEL=LOG_INFO"
      - "WRITE_TIMEOUT=1800"
      - "WRITE_JITTER=1800"
      - "WRITE_THREADS=4"
      - "FLUSH_DEAD_DATA_INTERVAL=3600"
    restart: always

  smtp:
    image: juanluisbaptiste/postfix
    container_name: librenms_smtp
    #volumes:
      ## ORIGINAL
      #- "/etc/localtime:/etc/localtime:ro"
      ## *NEITHER WORKED*
      #- smtp-localtime-volume:/etc/localtime:ro
      #- smtp-etc-localtime-volume:/etc/localtime:Z
      ## *ALWAYS GETTING ERROR*
      # ERROR: for smtp  Cannot create container for service smtp: source is not directory
      ## I believe it's because this folder doesn't even exist, it's a RO share ultimately
      ## since on Windows /etc/localtime doesn't exist, hence the error.
      ## By taking the volume out entirely, it works!
      ##
    environment:
      - "SERVER_HOSTNAME=librenms.example.com"
      - "SMTP_SERVER=${SMTP_SERVER}"
      - "SMTP_USERNAME=${SMTP_USERNAME}"
      - "SMTP_PASSWORD=${SMTP_PASSWORD}"
    restart: always

  librenms:
    image: librenms/librenms:latest
    container_name: librenms
    domainname: example.com
    hostname: librenms
    ports:
      - target: 80
        published: 80
        protocol: tcp
    depends_on:
      - db
      - memcached
      - rrdcached
      - smtp
    volumes:
      ## ORIGINAL
      #- "./librenms:/data"
      ##
      - lnms-data-volume:/data:Z
    environment:
      - "TZ=${TZ}"
      - "PUID=${PUID}"
      - "PGID=${PGID}"
      - "DB_HOST=db"
      - "DB_NAME=${MYSQL_DATABASE}"
      - "DB_USER=${MYSQL_USER}"
      - "DB_PASSWORD=${MYSQL_PASSWORD}"
      - "DB_TIMEOUT=30"
    env_file:
      - "./librenms.env"
    restart: always

  cron:
    image: librenms/librenms:latest
    container_name: librenms_cron
    domainname: example.com
    hostname: librenms
    depends_on:
      - librenms
    volumes:
      ## ORIGINAL
      #- "./librenms:/data"
      ##
      - lnms-data-volume:/data:Z
    environment:
      - "TZ=${TZ}"
      - "PUID=${PUID}"
      - "PGID=${PGID}"
      - "DB_HOST=db"
      - "DB_NAME=${MYSQL_DATABASE}"
      - "DB_USER=${MYSQL_USER}"
      - "DB_PASSWORD=${MYSQL_PASSWORD}"
      - "DB_TIMEOUT=30"
      - "SIDECAR_CRON=1"
    env_file:
      - "./librenms.env"
    restart: always

  syslog-ng:
    image: librenms/librenms:latest
    container_name: librenms_syslog
    domainname: example.com
    hostname: librenms
    depends_on:
      - librenms
    ports:
      - target: 514
        published: 514
        protocol: tcp
      - target: 514
        published: 514
        protocol: udp
    volumes:
      ## ORIGINAL
      #- "./librenms:/data"
      ##
      - lnms-data-volume:/data:Z
    environment:
      - "TZ=${TZ}"
      - "PUID=${PUID}"
      - "PGID=${PGID}"
      - "DB_HOST=db"
      - "DB_NAME=${MYSQL_DATABASE}"
      - "DB_USER=${MYSQL_USER}"
      - "DB_PASSWORD=${MYSQL_PASSWORD}"
      - "DB_TIMEOUT=30"
      - "SIDECAR_SYSLOGNG=1"
    env_file:
      - "./librenms.env"
    restart: always

volumes:
  db-mysql-volume:
    external: false
  rrd-librenms-volume:
    external: false
  rrd-journal-volume:
    external: false
  lnms-data-volume:
    external: false

Tried this on W10 server and the smtp one keeps crashing or restarting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants