Updating in a docker?

Hello

This is the 1st time I have needed to update since I have installed in a docker. From the terminal session I did a “pip3 install --upgrade homeassistant” but the version is still 0.54 and when I try to do it again, it says already updated etc.

I take it I haven’t done something correctly. I was hoping to keep the same docker and update rather than keep creating a new ones each update. Or is that the only way?

Cheers
Mark

I run HomeAssistant in a Docker container on my QNAP. My config files are all in a shared folder. To update, I just create a new container with the latest HomeAssistant version and map it to my shared config folder. Easy peasy.

thanks figured someone would say this :slight_smile:
I was hoping to just upgrade so I don’t need to setup the static ip etc… I know I am lazy :slight_smile:

If done properly, there should be NO config required.
Stop HA version_old
Create and start HA version_new
Ports and IP are based on host server

I run Home Assistant in a shell script that will auto-update any time I re-run the script controlling execution of the container:

docker.home-assistant.sh:

IMAGE=homeassistant/home-assistant
NAME=home-assistant

if ! docker pull $IMAGE | tee /dev/stderr | grep -q "Image is up to date"
then
  echo "removing old $NAME for $IMAGE"
  docker stop $NAME
  docker rm -f $NAME
fi

if ! docker ps --filter=name="$NAME" --filter=status="running" | grep $NAME
then
  echo "running $NAME"

docker run \
    -d \
    --name $NAME \
    --restart always \
    -p 8133:8133 \
    -e PUID=1001 -e PGID=1001 \
    -e TZ='America/New York' \
    -v /appdata/homeassistant:/config \
    --privileged \
    -v /dev/ttyACM0:/dev/ttyACM0 \
    -v /dev/ttyUSB0:/dev/ttyUSB0 \
    --device /dev/ttyUSB0 \
    -v /etc/localtime:/etc/localtime:ro \
    -e VIRTUAL_HOST=hass.mydomain.com \
    -e VIRTUAL_PORT=8133 \
    $IMAGE
fi
5 Likes

I was getting loads of errors when I was set as my host IP address, hence I moved to a different one

Interesting.

What type errors?
What did you have “set as my host IP address”?

Something like @billimek does should just work seemlessly with no further changes. If changes needed there may be minor change to container build required.

I get this option to set as host

All loads ok but then issues galore. It appears it cannot talk to most things from outside of the host IP (NAS is .100) but when I set it’s own ip of .102 all is great

2017-10-09 08:19:42 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (_mysql_exceptions.OperationalError) (1045, "Access denied for user 'hauser'@'NAS' (using password: YES)") (retrying in 3 seconds)
2017-10-09 08:19:45 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (_mysql_exceptions.OperationalError) (1045, "Access denied for user 'hauser'@'NAS' (using password: YES)") (retrying in 3 seconds)
2017-10-09 08:19:45 ERROR (MainThread) [homeassistant.setup] Setup failed for recorder: Component failed to initialize.
2017-10-09 08:19:45 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of history. Setup failed for dependencies: recorder
2017-10-09 08:19:45 ERROR (MainThread) [homeassistant.setup] Setup failed for history: Could not setup all dependencies.
2017-10-09 08:19:47 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of logbook. Setup failed for dependencies: recorder
2017-10-09 08:19:47 ERROR (MainThread) [homeassistant.setup] Setup failed for logbook: Could not setup all dependencies.
2017-10-09 08:19:54 WARNING (SyncWorker_7) [homeassistant.components.emulated_hue] When targetting Google Home, listening port has to be port 80
2017-10-09 08:19:57 WARNING (MainThread) [homeassistant.setup] Setup of sensor is taking over 10 seconds.
2017-10-09 08:19:57 WARNING (MainThread) [homeassistant.setup] Setup of media_player is taking over 10 seconds.
2017-10-09 08:19:58 WARNING (MainThread) [homeassistant.setup] Setup of device_tracker is taking over 10 seconds.
2017-10-09 08:19:58 WARNING (MainThread) [homeassistant.setup] Setup of light is taking over 10 seconds.
2017-10-09 08:20:04 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform sonos
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/util/connection.py", line 83, in create_connection
    raise err
  File "/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
OSError: [Errno 113] No route to host

doesn’t connect to camera, xiaomi etc etc…

Is this Synology or some other NAS?

What is other option available?

Error cause is docker cannot bind to port I believe.

Docker has some very advanced networking under hood that has been hidden, made accessible and simplified for user.

If you create a docker container, the container will not be able to connect OUT to anything on network that host can see. It runs it’s on internal private network. INCOMING/OUTGOING request to/from docker container will be blocked unless explicitly allowed. For example, another server cannot ping docker container unless this was allowed (local server 2 ping container fail/container ping local server 2 fail/container ping Google fail)

When set “net=host”, I believe you affectively mirror all host ports to docker container port. Host port 80=container port 80, host port 443 = container port 443 and on and on for all ports 1-65535. This now allows another server to ping container (local server 2 ping container@host port 80 OK). More importantly, you can now serve webpage at port 80 or 8123. This also allow container connect to external web (container ping local server 2 OK/container ping Google OK) This OK but this is not optimal from security perspective and because alternative method to this provides very cool and convenient function and flexibility.

The alternative to “–net=host” is using “-p” option. So, like in @billimek example, he use “-p 8133:8133”. This means only port 8133 from host is mapped to port 8133 of container (server 2 ping container@host port 8133 OK). This also allows container access to web (container ping server 2 ok/container ping Google OK) In this case you must explicitly allow traffic IN on required ports(server 2 ping container@port 80 FAIL). You may also do stuff like “-p 8888:8133” (server 2 ping container@ host port 8133 FAIL/server 2 ping container@ host port 8888 OK)

HOW THIS RELATE TO YOUR ERROR
I suspect when error occur you are NOT using “net=host” but ALSO NOT set port with -p. All errors from log and errors you describe sound like blocked network basically. Setting -p HostPort:ContainerPort may clear these errors

EDIT
I think I remember Synology has “host” or “bridge”. I never use host but use bridge. I assume with host Synology has created some method for allowing you create IP for container(they hid a lot of the network setup). Bridge would be method that allow use of -p option.

wowza… thanks for the great reply. I will look into this and it is a QNAP NAS

“NAT” mode is same as using “-p” for qnap i believe

ok I have been playing with the command line and I thought this would sort it out… exactly the same problems… I am guessing a problem with the QNAP.

I suppose I can still script it as above but use bridge mode and set the static IP address?

This is what I tried and failed with

docker run -d -p 8123:8123 --name home-assistant --restart=always --net=host --privileged -v /share/CACHEDEV4_DATA/Container/test/:/config --device /dev/ttyACM0 homeassistant/home-assistant

NAT mode I think

docker run -d -p 8123:8123 --name=home-assistant --restart=always -v /share/CACHEDEV4_DATA/Container/test/:/config --device=/dev/ttyACM0 homeassistant/home-assistant

Here’s the command I use on my qnap for a new Docker container with zwave:

docker run -d --name=“hass” -v /share/Docker/HASS:/config
–privileged -v /dev/ttyACM0:/dev/ttyACM0 -p 8123:8123
homeassistant/home-assistant:0.54 python -m homeassistant --config
/config