Is it still necessary to run HA and esphome in two separate docker containers?

Hi,

up until now, I am using a couple of Tasmota-devices. As esphome and HA are getting closer and closer, I thought that esphome would be a part of HA. After some research, I found some posts from late 2022 that you have to run esphome in a separate docker container.

Is this still true? Do I need to set up esphome in its own container? (I am running HA in docker as well…)

Thanks for clarification,
Chris

They’re different pieces of software, so they have to run in their own container.

That’s one of the basics of containers. Every piece of software in its own container.

but it basically comes down to what you are running.
In HAos it is just an add-on (which is a docker).

Thank you both for the clear response.

I went to this page (-> Docker) to find some details about how to get my compose.yaml together, but there is nothing helpful there. The reference to documentation on https://esphome.io/ does not help either.

Where do I find the documentation on how to set up a esphome docker compose.yaml?! I like to use portainer to set up my containers…

Thank for any hint to the right documentation or some useful examples.

Chris

I use docker compose and this is mine esphome config for it

  esphome:
    container_name: esphome
    image: esphome/esphome
    volumes:
      - /opt/esphome/config:/config
      - /etc/localtime:/etc/localtime:ro
#    ports:
#      - 6052:6052
    depends_on:
      - homeassistant
    restart: always
    privileged: true
    network_mode: host

Hi @ddaniel,

thank you for the quick response. There is an example on the official esphome page (Getting Started with the ESPHome Command Line — ESPHome), but it does not explain much.

e.g.:

  • Why did you comment your ports?
  • Why privileged?
  • In the esphome example, there are environment variables for username and password. What for?
  • What about resources? How much RAM/CPU does this container need?

I am no docker pro and I would like to have some additional explanations to get comfortable with this image… :slight_smile:

EDIT: in the official docker page (Docker), he image is pull like this: image: ghcr.io/esphome/esphome
On the official esphome page, there is this: image: ghcr.io/esphome/esphome
What is the difference? Is it the same image or different source?

I’m not also docker pro or even it pro.
I commented out ports because it has to run in host mode. I don’t remember exactly why, but probably I was testing things.
Maybe privileged isn’t necessary but as my local network isn’t reachable from out side I don’t care. It does work.
Maybe sometimes I will deal with but for now I don’t see any reason why.
Esphome container use marginal amount of cpu and ram. Cpu usage is on average on 0.04% and ram usage on average is 25 mb.
And you don’t need any username or password for it. I mean you can set username and password for every container if you want to prevent other users from accessing it. I don’t know why someone put it in some example.
Edit:
I don’t know. I’m just using official esphome docker image. Anyone can build a docker image and put it on docker hub.

Because he’s using host network mode

That gives the container access to devices (and more) without having to map them.

Those are used by the container at runtime.

Most of the time next to nothing. When you’re compiling code for a device it’ll use more.

Docker Hub is the original repository of Docker images. There are many other options these days, and Google’s (ghcr.io) is a popular free one.

The compose reference will help explain a lot of what’s going on.

Hi @Tinkerer,

thank you for your reply. I just have created a compose.yaml and started the container. Seems to run okay, even without privileded rights.

  esphome:
    container_name: esphome
    image: ghcr.io/esphome/esphome:stable
    volumes:
      - /home/uadmin/Docker/esphome/esphome_config:/config
    ports:
      - 6052:6052
    restart: unless-stopped
#    privileged: true
    networks:
      macvlan30:
        ipv4_address: 192.168.30.21
#    deploy:
#      resources:
#         limits:
#            memory: 128mb
    logging:
      driver: gelf
      options:
        gelf-address: udp://10.10.10.2:12201
        tag: esphome
    environment:
      - TZ=Europe/Zurich
#      - PUID=1000
#      - PGID=1000

I will try to set up a d1 mini with a DHT-sensor tomorrow. :slight_smile:

You are very smart guy. Shame that people around you doesnt understand how smart you are.