Pulling new docker image does not update

So I am running HA on docker and using docker-compose. My current version is 0.81.2 when using this method.

I have stopped the container, completed a pull in docker-compose, and my version is the same.

Does the docker image lag behind the updates this much?

Compose File:

services:
homeassistant:
container_name: home-assistant
devices:
- /dev/ttyACM0:/dev/ttyACM0
image: homeassistant/home-assistant
network_mode: host
restart: always
volumes:
- /usr/local/dockerconfig/homeassistant:/config:rw
- /etc/localtime:/etc/localtime:ro
version: ‘3.0’

I’m not sure if there is a difference using docker-compose (I never use it) but when I want to update to the latest version I delete the existing container, do a pull then re-create the container using my docker run command.

Or more often I just use Portainer to do it. there is an option to pull the latest image when you tell Portainer to re-create the container.

docker-compose pull && docker-compose down && docker-compose up -d

That will pull the latest images for the entire stack, bring down the entire docker stack, and start it back up

I just tried that but it won’t start up because the containers already exist… is that because I didn’t use docker compose to create them in the first place? should I delete my existing containers first?

You may want to add “:latest” at the end of the image tag in your docker-compose file

This is my entry and it pulls the latest image every time.
image: homeassistant/home-assistant:latest

If it wasn’t created with docker compose it won’t work.

1 Like

Gotcha. I thought that might be it. So I just removed the containers and ran compose and everything came up. If I use watchtower to keep some containers up-to-date will that be a problem? Will I be able to use docker-compose as well say in a script? (Sometimes some containers go rogue and chew up memory so I’m thinking of an automation to run a script with docker-compose)
Also I assume I can still update through portainer if I want to?

I’ve never used watch tower. I don’t know.

Shouldn’t be a problem.

Yeah. I use portainer from time to time.

1 Like

The watchtower docs seem to indicate that you can use docker-compose to start up containers so I’m guessing that it will work. I only use watchtower for non-HA stuff anyway.

Apologies for not updating sooner.

It was a pebkac error in the way I was refreshing the container.

I had not actually setup the docker-compose completely and still needed to run the command line docker command to delete the image and pull it back down again.

For me it was because the doc states the generic docker image name. I was using the raspberry pi 2 image so I had to do…

sudo docker pull homeassistant/raspberrypi2-homeassistant:latest

Except now I have two images one with tag latest and one with tag

If I fire up a new container with the latest image it doesn’t have any of my configs, which makes sense if it’s a new container.

That’s why you keep persistent data out of the container and “bind-mount” into the container at start-time. Containers are ephemeral and everything in them is gone, once they are deleted.

The docker-compose file from above is missing an important mount:

services:
  homeassistant:
    container_name: home-assistant
    devices:
    - /dev/ttyACM0:/dev/ttyACM0
    image: homeassistant/home-assistant
    network_mode: host
    restart: always
    volumes:
    - /usr/local/dockerconfig/homeassistant:/config:rw
    - /etc/localtime:/etc/localtime:ro
    # Add this:
    - /my-config-directory:/config
    version: ‘3.0’

??
- /usr/local/dockerconfig/homeassistant:/config:rw

It is already there.

All make sense. Problem is that the official install docs don’t seem to cover this, thus when you follow their updates steps you could lose data or at least not have your data loaded into the updated container.

For example this is the install doc command.
docker run -d --name="home-assistant" -v /PATH_TO_YOUR_CONFIG:/config -v /etc/localtime:/etc/localtime:ro --net=host homeassistant/raspberrypi3-homeassistant
source: https://www.home-assistant.io/docs/installation/docker/
This downloads an image with no tags (docker images shows TAG= <none> )

The update command listed is sudo docker pull homeassistant/home-assistant:latest which downloads an image with tag latest

… and that’s it. No further instructions for update aside from “restart” which doesn’t update the container. When I fire up another container using the original install command but specify the latest image it does not pull from my configs in /PATH_TO_YOUR_CONFIG (which of course I updated with my actual path). I also switch the image to homeassistant/raspberrypi2-homeassistant to match my pi. I need to go back to see if I made a mistake when updating the /PATH_TO_YOUR_CONFIG when running the latest image. Hoping that’s all it is.

o.O

Eh?

Installation with Docker is straightforward. Adjust the following command so that /PATH_TO_YOUR_CONFIG points at the folder where you want to store your configuration and run it:

$ docker run -d --name="home-assistant" -v /PATH_TO_YOUR_CONFIG:/config -v /etc/localtime:/etc/localtime:ro --net=host homeassistant/home-assistant
  version: '3'
  services:
    homeassistant:
      container_name: home-assistant
      image: homeassistant/home-assistant
      volumes:
        - /PATH_TO_YOUR_CONFIG:/config
        - /etc/localtime:/etc/localtime:ro
      restart: always
      network_mode: host

Prematurely submitted the response. Updated with more detail.

Because, Docker, with no tag specified, pulls ‘latest’

what is the docker command you are using to run the container?

This, from the documentation, as per above
docker run -d --name="home-assistant" -v /PATH_TO_YOUR_CONFIG:/config -v /etc/localtime:/etc/localtime:ro --net=host homeassistant/raspberrypi3-homeassistant