Portainer do not recognize any images/containers on RPI3

HI :slight_smile:
I’m currently trying to move/integrate node_red within docker and home assistant. I was able to install home assistant, node red, esp home and portainer from docker-compose.yaml file. However the problem is that Portainer do not recognize any of the containers same with esp home that cannot access the usb ports.

version: '2'
services:
  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - /pi/home/haconfig:/config
      - /etc/localtime:/etc/localtime:is
    restart: unless-stopped
    privileged: true
    network_mode: host
    devices:
	  - /dev/ttyUSB0:/dev/ttyUSB0		  
  nodered:
    container_name: node-red
    image: "docker.io/nodered/node-red:latest"
    volumes:
      - /pi/home/noderedconf:/config
      - /etc/localtime:/etc/localtime:is
    restart: unless-stopped
    privileged: true
    network_mode: host
    devices:
	  - /dev/ttyUSB0:/dev/ttyUSB0		  
  esphome:
    container_name: homeassistant
    image: "docker.io/esphome/esphome:latest"
    volumes:
      - /pi/home/esphomeconf:/config
      - /etc/localtime:/etc/localtime:is
    restart: unless-stopped
    privileged: true
    network_mode: host
    devices:
	  - /dev/ttyUSB0:/dev/ttyUSB0

image

I would be glad if you could somehow point me to right solution, I spent too much time on trying to solve it :frowning:
Happy holidays! :christmas_tree:

I see you’ve name the esphome container the same as the home assistant. That’s one issue you may want to fix.

Did you install poetainer on the same docker host as the other containers

@bdollerup Thank you for an answer. Names are correct in my original file, I had problem copying it and made mistake. I apologize. I installed everything just running command docker compose up -d. All of it is running at the same RPI. How could I check it or change it? I’m still experimenting with it so can easily start from scratch :wink:

Can you share the docker compose file for portainer?

version: '2'

services:

homeassistant:

container_name: homeassistant

image: "ghcr.io/home-assistant/home-assistant:stable"

volumes:

- /pi/home/haconfig:/config

- /etc/localtime:/etc/localtime:is

restart: unless-stopped

privileged: true

network_mode: host

ports:

- target: 8123

published: 8123

protocol: tcp

mode: host

devices:

  \- /dev/ttyUSB0:/dev/ttyUSB0		  
nodered:

container_name: node-red

image: "docker.io/nodered/node-red:latest"

volumes:

- /pi/home/noderedconf:/config

- /etc/localtime:/etc/localtime:is

restart: unless-stopped

privileged: true

network_mode: host

ports:

- target: 1880

published: 1880

protocol: tcp

mode: host

devices:

  \- /dev/ttyUSB0:/dev/ttyUSB0		  
esphome:

container_name: esphome

image: "docker.io/esphome/esphome:latest"

volumes:

- /pi/home/esphomeconf:/config

- /etc/localtime:/etc/localtime:is

restart: unless-stopped

privileged: true

network_mode: host

ports:

- target: 6052

published: 6052

protocol: tcp

mode: host

devices:

  \- /dev/ttyUSB0:/dev/ttyUSB0
portainer:

container_name: portainer

image: "docker.io/portainer/portainer:latest"

volumes:

- /pi/home/portconf:/config

- /etc/localtime:/etc/localtime:is

restart: unless-stopped

privileged: true

network_mode: host

ports:

- target: 9000

published: 9000

protocol: tcp

mode: host

devices:

- /dev/ttyUSB0:/dev/ttyUSB0


There might be some formatting issues, I uploaded it via phone :confused:

Portainer requires access to the docker sock to manage it. Under volumes you should have this specified:

    - '/var/run/docker.sock:/var/run/docker.sock'

Host networking, privileged, and devices mapping is not necessary for portainer. Full install directions for portainer here:

You can always convert a run command to compose with this tool

https://www.composerize.com/

The run command on the install directions would turn to the following compose

version: '3.3'
services:
    portainer-ce:
        ports:
            - '8000:8000'
            - '9443:9443'
        container_name: portainer
        restart: always
        volumes:
            - '/var/run/docker.sock:/var/run/docker.sock'
            - 'portainer_data:/data'
        image: 'portainer/portainer-ce:latest'

Im testing this file now:

version: '2'
services:
  portainer:
        container_name: portainer
        privileged: false
        restart: unless-stopped
        environment:
            - TZ=Europe/Iceland
        volumes:
            - '/home/pi/portconf:/config'
        ports:
            - '9000:9000'
        image: 'docker.io/portainer/portainer-ce:latest'
  home-assistant:
        container_name: homeassistant
        privileged: false
        restart: unless-stopped
        environment:
            - TZ=Europe/Iceland
        volumes:
            - '/home/pi/haconfig:/config'
        ports:
            - '8123:8123'
        image: 'ghcr.io/home-assistant/home-assistant:stable'
  nodered:
        container_name: nodered
        privileged: false
        restart: unless-stopped
        environment:
            - TZ=Europe/Iceland
        volumes:
            - '/home/pi/noderedconf:/config'
        ports:
            - '1880:1880'
        image: 'docker.io/nodered/node-red:latest'
  esphome:
        container_name: esphome
        privileged: false
        restart: unless-stopped
        environment:
            - TZ=Europe/Iceland
        volumes:
            - '/home/pi/esphomeconf:/config'
        ports:
            - '6052:6052'
        image: 'docker.io/esphome/esphome:latest'

And see if that will work, I used the link from you :wink:
How to also share usb ports so esphome can see it, that I could upload firmware to esp?

EDIT: I tested, portainer still cant detect my other images I have no clue how to solve it. First time when I installed it with:

docker run -d \
  --name portainer \
  --privileged \
  --restart=unless-stopped \
  -e TZ=Europe/Iceland \
  -v /home/pi/portconf:/config \
  -p 9000:9000 \
  docker.io/portainer/portainer-ce:latest

It worked fine and I could see all the images :confused:

Your first time you ran it in privileged mode, which is why it saw everything, and your compose you are using now does not have privileged mode, as it has “privileged: false”.

Privileged mode is not necessary for portainer if you map the docker sock volume. Based on your compose above use this instead

version: '2'
services:
  portainer:
        container_name: portainer
        privileged: false
        restart: unless-stopped
        environment:
            - TZ=Europe/Iceland
        volumes:
            - '/var/run/docker.sock:/var/run/docker.sock'
            - '/home/pi/portconf:/config'
        ports:
            - '9000:9000'
        image: 'docker.io/portainer/portainer-ce:latest'
  home-assistant:
        container_name: homeassistant
        privileged: false
        restart: unless-stopped
        environment:
            - TZ=Europe/Iceland
        volumes:
            - '/home/pi/haconfig:/config'
        ports:
            - '8123:8123'
        image: 'ghcr.io/home-assistant/home-assistant:stable'
  nodered:
        container_name: nodered
        privileged: false
        restart: unless-stopped
        environment:
            - TZ=Europe/Iceland
        volumes:
            - '/home/pi/noderedconf:/config'
        ports:
            - '1880:1880'
        image: 'docker.io/nodered/node-red:latest'
  esphome:
        container_name: esphome
        privileged: false
        restart: unless-stopped
        environment:
            - TZ=Europe/Iceland
        volumes:
            - '/home/pi/esphomeconf:/config'
        ports:
            - '6052:6052'
        image: 'docker.io/esphome/esphome:latest'

This explains why

Thank You for your time! It worked but only when I did privileged to True :wink:
Could you also maybe point me out how can I share my usb devices from RPI to docker, so I can set up esp? :blush:

That’s odd the volume mapping for /var/run/docker.sock didn’t work for portainer. You should avoid using the privileged mode in docker when possible, and I generally stick to the official install directions for each container on how to define the docker parameters when I can, and only modify them if absolutely necessary and the changes are fully understood. If you are using privileged mode for portainer make sure you set a strong password and I would definitely not expose portainer outside the lan or through any proxies.

For ESP, I don’t use it myself, but, unlike portainer, its install directions actually say to use privileged mode. Privileged mode in this case for ESP would be needed to access the usb hardware on the host, which will be necessary for flashing. Portainer does not need access to any hardware mappings on the host so that is why priviledged shouldn’t be needed (although you might have some other config on your OS that is blocking it from working right I am not aware of) . Also, if someone hacks your network, they can do much more damage with access to portainer versus ESP, as portainer can be used to create any other docker process they want with full access to your system.

Install directions for esp in docker are here - Getting Started with the ESPHome Command Line — ESPHome

In your compose example above, just change "privileged from “false” to “true” under the esphome section.

On another note, with portainer working, you can actually use it instead of the command line to install and manage all your containers, including ESPhome. I use portainer too, and the only thing I use the command line for now is to manage and update portainer itself. Here is how you can use docker compose inside of the portainer’s “stack” feature. It is a nice feature as you can quickly and easily make changes to your compose, and just click the button to “update the stack” to redeploy the container, versus needing to use the command line for docker compose.

Thank you for all those information supported with extra resources! I changed privileged mode to false on portainer :wink: However esphome still cant detect my esp connected to raspberry, even though if I do lsusb on raspberry system it recognize connection…

UPDATE: I did mapping with -device option ttyUSB0 and it worked :smiley: now Bluetooth and google home integration left…and few other things, but this is a step ahead after weeks of struggle!

1 Like