How to access the UI of the ESPHome docker container when running it locally? (mac)

I am trying to run the ESPHome using the example of the official website (minus the difference in some folder names).

version: '3'
services:
  esphome:
    container_name: esphome
    image: esphome/esphome
    volumes:
      - ./esphome/config:/config
      - ./esphome/cache:/cache
      - /etc/localtime:/etc/localtime:ro
    restart: always
    privileged: true
    network_mode: host

The problem that I have is that it exposes a UI on port 6052 and I have no idea how to open it.

I have tried localhost:6052, my-ip:6052 and it does not work.

How can I open port 6052 in a browser?

Removing network_mode: host and manually adding the port folder let me see the UI, but it can not connect to the outside to get the libraries needed to build.

Am also running on host and use the ip of the machineā€¦no naming ā€¦ and the port of courseā€¦

192.168.10.129:6052

Looks like this is a problem with mac ( I am using a mac). The docker run command from the FAQ works but I need to set up it as a part of a docker-compose and I can not find the way.

docker run --rm -p 6052:6052 -e ESPHOME_DASHBOARD_USE_PING=true -v "${PWD}":/config -it esphome/esphome

Using

services:
  esphome:
    container_name: esphome
    image: esphome/esphome
    ports:
      - '6052:6052'
    environment:
      - ESPHOME_DASHBOARD_USE_PING=true
    volumes:
      - ./esphome/config:/config
      - ./esphome/cache:/cache
      - /etc/localtime:/etc/localtime:ro

brings the UI, I see my config files, and If I open a device log it eventually opens, but the dashboard shows it continuously as offline.

I also see continuos 304 logs on the terminal:

esphome  | 2023-02-19 18:59:43,744 INFO 304 GET /devices (172.22.0.1) 3.31ms
esphome  | 2023-02-19 18:59:49,732 INFO 304 GET /devices (172.22.0.1) 2.36ms
esphome  | 2023-02-19 18:59:55,343 INFO 304 GET /devices (172.22.0.1) 2.98ms
esphome  | 2023-02-19 19:00:01,839 INFO 304 GET /devices (172.22.0.1) 2.23ms
esphome  | 2023-02-19 19:00:07,600 INFO 304 GET /devices (172.22.0.1) 3.03ms
esphome  | 2023-02-19 19:00:12,739 INFO 304 GET /devices (172.22.0.1) 4.34ms
esphome  | 2023-02-19 19:00:18,523 INFO 304 GET /devices (172.22.0.1) 3.35ms
esphome  | 2023-02-19 19:00:24,765 INFO 304 GET /devices (172.22.0.1) 3.49ms
esphome  | 2023-02-19 19:00:31,047 INFO 304 GET /devices (172.22.0.1) 2.35ms
esphome  | 2023-02-19 19:00:36,344 INFO 304 GET /devices (172.22.0.1) 3.74ms
esphome  | 2023-02-19 19:00:41,608 INFO 304 GET /devices (172.22.0.1) 2.48ms
esphome  | 2023-02-19 19:00:47,520 INFO 304 GET /devices (172.22.0.1) 4.46ms
1 Like

I have no knowledge on the mac install but this is what I use

docker run -d --name=esphome --net=host -e TZ=Europe/Paris -v /home/etcetcetc/docker/homeassistant1/esphome:/config esphome/esphome

That doesnā€™t work on Mac, see Frequently Asked Questions ā€” ESPHome

As mentioned, do not know macā€¦I do know that e.g. Windows also has no ā€˜hostā€™ mode. What do you get when you use host on mac (is it supported?)

When I use host it runs and I get no error but opening localhost:6052 or my-mac-ip:6052 resolves nothing.

Anywayā€¦ using the docker-compose I posted before, after I clicked ā€œupdate devicesā€ it seems to find the only esp32 device that I know is online.

It just shows an extra popup when I click the logs

But I suppose I can live with it.

As I address all stuff from outside the machine, only using IP of the ā€˜serverā€™ ā€¦works for me but (again) not known to mac-challenges

I ran into a similar issue when trying to configure an ESPHome container on my Mac. Specifically, I couldnā€™t access the ESPHome dashboard front end and once I figured that out, all of my ESP devices were showing offline even though they were online. The issue is Docker for Mac does not support the network_mode=host, so you have to manually expose port 6052 as mentioned above.

While this allows you to access the ESPHome dashboard, it relies on the host network mode for discovering ESP devices via mDNS. This does not work unless youā€™re using the host network mode, so the alternative is to set the environment variable ESPHOME_DASHBOARD_USE_PING=true in your docker compose which will use ICMP checks instead of mDNS to check the status of your ESP devices.

Hereā€™s an example of my docker compose entry for ESPHome. Of note, I found that I had to define platform: "linux/amd64" to force using an amd64 container. Iā€™m on a Mac Mini M2 and when it uses the ARM containers, thereā€™s some dependencies that werenā€™t working.

services:
  esphome:
    container_name: esphome
    platform: "linux/amd64"
    image: ghcr.io/esphome/esphome
    environment:
      - ESPHOME_DASHBOARD_USE_PING=true
    volumes:
      - "${PWD}/config:/config"
      - "/etc/localtime:/etc/localtime:ro"
    restart: always
    privileged: true
    ports:
      - 6052:6052
1 Like