0

I'm still a newbie in the Docker area. I'm just getting confused about this from this Docker-run command:

docker run -d --name fritzbox_smarthome_exporter -p 9103:9103 \
  -v $(pwd)/boxcert.cer:/fritzbox.pem:ro \
  -e PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
  -e PASSWORD=ChefsPassWord \
  -e USERNAME=chef \
  jaymedh/fritzbox_smarthome_exporter '-noverify=false' '-url=http://fritz.box' '-cert=/fritzbox.pem'

to create a corresponding docker-compose.yml file.

Can someone enlighten a blind person? Thanks.

This is my design:

version: '3.8'
services:
  fritzbox_smarthome_exporter:
    image: 'jaymedh/fritzbox_smarthome_exporter:latest'
    restart: unless-stopped
    ports:
      - '9103:9103'
environment:
      USERNAME=Chef
      PASSWORD=cHefsPw
      PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
volumes: 
      - $(pwd)/boxcert.cer:/fritzbox.pem:ro
command: noverify=false url=http://192.168.0.2 cert=/fritzbox.pem

But Portainer throws the following error message:

failed to deploy a stack: validating /data/compose/25/docker-compose.yml: services.fritzbox_smarthome_exporter1.environment must be a mapping

Even if I replace the variable with the regular path on the system ( - /opt/fritz_smarthome_exporter/boxcert.cer:/fritzbox.pem:ro ), I get an error.

version: '3.8'
services:
  fritzbox_smarthome_exporter:
    image: 'jaymedh/fritzbox_smarthome_exporter:latest'
    restart: unless-stopped
    ports:
      - '9103:9103'
environment:
      USERNAME=Chef
      PASSWORD=cHefsPw
      PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
volumes: 
      - /opt/fritbox_smarthome_exporter/boxcert.cer /fritzbox.pem:ro
command: noverify=false url=http://192.168.0.2 cert=/fritzbox.pem

the Error: failed to deploy a stack: validating /data/compose/38/docker-compose.yml: volumes must be a mapping

can anyone help me ?

0

2 Answers 2

0

Indentation looks incorrect...Docker Composerize can help you: https://www.composerize.com

version: '3.3'
services:
    fritzbox_smarthome_exporter:
        container_name: fritzbox_smarthome_exporter
        ports:
            - '9103:9103'
        volumes:
            - ${PWD}/boxcert.cer:/fritzbox.pem:ro
        environment:
            PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
            PASSWORD: ChefsPassWord
            USERNAME: chef
        labels:
            - 'http://fritz.box'
        image: jaymedh/fritzbox_smarthome_exporter
        restart: unless-stopped
2
  • 1
    why does this list "true" twice as environment variables?
    – Jesusaur
    Commented Oct 16, 2023 at 18:46
  • @Jesusaur good catch; I updated the docker-compose.yml...I had copied it from output at www.coposerize.com based on OP question's syntax. Commented Oct 16, 2023 at 19:42
0

The format of your environment variables is incorrect. Additionally, using bash expansion for the volume path won't work, but you can use a relative path:

version: '3.8'
services:
  fritzbox_smarthome_exporter:
    image: 'jaymedh/fritzbox_smarthome_exporter:latest'
    restart: unless-stopped
    ports:
      - '9103:9103'
    environment:
      USERNAME: Chef
      PASSWORD: cHefsPw
      PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    volumes: 
      - ./boxcert.cer:/fritzbox.pem:ro
    command: "noverify=false url=http://192.168.0.2 cert=/fritzbox.pem"

You can read more about the docker compose file syntax in the official docs

2
  • Hello, unfortunately that still doesn't work. I get the following error: failed to deploy a stack: validating /data/compose/40/docker-compose.yml: services.fritzbox_smarthome_exporter must be a mapping
    – VaraBiker
    Commented Oct 17, 2023 at 8:00
  • @VaraBiker whoops, sorry, my indentation was incorrect, but I've fixed it.
    – Jesusaur
    Commented Oct 17, 2023 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.