Dockerfile and Dockerfile.dev, how to use it for a local docker image

Hi, all, please help:
I’m new to here, following the development Doc: Set up development environment, I can run my HA local src folder with VS-code in Ubuntu 24.04 docker.
Now I need to build / run a docker-image running without VS-code.

in the src folder, there are 2 Dockerfiles: Dockerfile and Dockerfile.dev, using:

$ docker build -f Dockerfile.dev -t home_assistant:dev .

$ docker run -d --name ha_dev -v $(pwd)/config:/config -v $(pwd):/usr/src/homeassistant -p 8123:8123 home_assistant:dev

I got the docker image run, no errors, but the http://localhost:8123/ not work.
What’s wrong, pls help. Thanks.

Ok so a couple of things:

  1. Did the build complete successfully?
  2. Does the run command give you anything?
  3. Is the ‘normal’ container running on the same port?

We’ll need much more information to be able to help here, post the complete outputs of the commands to start.
Perform a docker logs ha_dev

Thanks. seems no any errors:

abcxyz@ubuntu:~/Desktop/core$ 
abcxyz@ubuntu:~/Desktop/core$ 
abcxyz@ubuntu:~/Desktop/core$ 
abcxyz@ubuntu:~/Desktop/core$ docker build -f Dockerfile.dev -t home_assistant:dev .
[+] Building 24.2s (18/18) FINISHED    docker:default
 => [internal] load build definition from Dockerfile.dev   
 => => transferring dockerfile: 1.89kB   
 => [internal] load metadata for ghcr.io/astral-sh/uv:latest   
 => [internal] load metadata for mcr.microsoft.com/vscode/devcontainers/base:debian     
 => [internal] load metadata for ghcr.io/alexxit/go2rtc:latest   
 => [internal] load .dockerignore     
 => => transferring context: 249B     
 => [stage-0 1/9] FROM mcr.microsoft.com/vscode/devcontainers/base:debian@sha256:30b0a0c004ca94d36c323ee993361a7e0ae25ea255ea125201e8a9587501c3 
 => => resolve mcr.microsoft.com/vscode/devcontainers/base:debian@sha256:30b0a0c004ca94d36c323ee993361a7e0ae25ea255ea125201e8a9587501c324    
 => [internal] load build context     
 => => transferring context: 255B     
 => FROM ghcr.io/astral-sh/uv:latest@sha256:5713fa8217f92b80223bc83aac7db36ec80a84437dbc0d04bbc659cae030d8c9     
 => => resolve ghcr.io/astral-sh/uv:latest@sha256:5713fa8217f92b80223bc83aac7db36ec80a84437dbc0d04bbc659cae030d8c9     
 => FROM ghcr.io/alexxit/go2rtc:latest@sha256:f394f6329f5389a4c9a7fc54b09fdec9621bbb78bf7a672b973440bbdfb02241   
 => => resolve ghcr.io/alexxit/go2rtc:latest@sha256:f394f6329f5389a4c9a7fc54b09fdec9621bbb78bf7a672b973440bbdfb02241   
 => CACHED [stage-0 2/9] RUN     apt-get update     && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-re
 commends   bluez  
 => CACHED [stage-0 3/9] COPY --from=ghcr.io/alexxit/go2rtc:latest /usr/local/bin/go2rtc /bin/go2rtc    
 => CACHED [stage-0 4/9] WORKDIR /usr/src   
 => CACHED [stage-0 5/9] COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv    
 => CACHED [stage-0 6/9] RUN --mount=type=bind,source=.python-version,target=.python-version     uv python install     && uv venv /home/vscode/ 
 => CACHED [stage-0 7/9] RUN git clone --depth 1 https://github.com/home-assistant/hass-release ~/hass-release     && uv pip install -e ~/hass- 
 => CACHED [stage-0 8/9] RUN --mount=type=bind,source=requirements.txt,target=requirements.txt     --mount=type=bind,source=homeassistant/packa 
 => CACHED [stage-0 9/9] WORKDIR /workspaces    
 => exporting to image     
 => => exporting layers    
 => => exporting manifest sha256:10eaea13b226697dccd1bbc5daeaa11e66d83841020ede1e2c03093d8a842c51     
 => => exporting config sha256:f1441712ebbb3097b638f70ad97c730b31e7ed4bb105332e303bbb17a872a572    
 => => exporting attestation manifest sha256:f025f6293d54226949e730ed341d09d6445e295c9199a98bc960f92a22e1d1d7     
 => => exporting manifest list sha256:37b7b460c0640c04d412db53005ef2f0de3d06f260986d610aa52b360adcf537   
 => => naming to docker.io/library/home_assistant:dev    
 => => unpacking to docker.io/library/home_assistant:dev     
abcxyz@ubuntu:~/Desktop/core$ 
abcxyz@ubuntu:~/Desktop/core$ 
abcxyz@ubuntu:~/Desktop/core$ 
abcxyz@ubuntu:~/Desktop/core$ 
abcxyz@ubuntu:~/Desktop/core$ docker run -d --name ha_dev -v $(pwd)/config:/config -v $(pwd):/usr/src/homeassistant -p 8123:8123 --restart=unless-stopped home_assistant:dev
b65bae9d8bc8005d08293350007097ae7ec0e05ef3da288f23d4a59d064edefc
abcxyz@ubuntu:~/Desktop/core$ 
abcxyz@ubuntu:~/Desktop/core$ 
abcxyz@ubuntu:~/Desktop/core$ 

no log output:

only no IP address & Port numbers show on the Portainer:

  • Can you execute docker logs ha_dev from the CLI to see what it returns?
  • The fact it isn’t showing the ports is strange, can you access it from the cli? ss | grep 8123 and telnet localhost 8123

My assumption is that the network of the container is not reachable, you can fix that by using the --net=host option when starting the container.

If that fails:

  • Can you take control over the container with Portainer and see if you can configure it through the UI to work?

Hi, @afsy_d , thanks.

abcxyz@ubuntu:~$ docker logs ha_dev
abcxyz@ubuntu:~$ 
abcxyz@ubuntu:~$ ss | grep 8123
abcxyz@ubuntu:~$ 
abcxyz@ubuntu:~$ telnet localhost 8123
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
abcxyz@ubuntu:~$ 

and when I added --net=host:

abcxyz@ubuntu:~$ docker run -d --name ha_dev -v $(pwd)/config:/config -v $(pwd):/usr/src/homeassistant -p 8123:8123 --restart=unless-stopped --net=host home_assistant:dev
WARNING: Published ports are discarded when using host network mode
17cfb71d0c6c2f4714a4d28004e40545000b8c429ba27b425d54c05877467680
abcxyz@ubuntu:~$ 
abcxyz@ubuntu:~$ 

That means the IP-port 8123 not open to outside.
But, my docker is working fine on the offical docker images, no such IP port problem.

How to fix this?

can not access the container CLI inside the Portainer.