gcgarner / IOTstack

docker stack for getting started on IOT on the Raspberry PI
GNU General Public License v3.0
1.5k stars 578 forks source link

Portainer.io - A new version is available 2.0.0 #203

Closed paolos7709 closed 3 years ago

paolos7709 commented 3 years ago

Hello team, I just installed IOTstack and when logged in into Portainer console, I see it's saying that new version is available. I see that new version 2.0.0 is available... I also see that new container is called "portainer/portainer-ce" and not "portainer/portainer" anymore. Will be IOTstack containers updated as well...?

Last but not least, good work you've done so far. Very useful project!

Paraphraser commented 3 years ago

The short answer is "when the maintainer of the Portainer image builds a new image based on the updated version of Portainer, and uploads that to Dockerhub." I hope that makes sense.

What you need to do from time to time is:

$ docker-compose -f ~/IOTstack/docker-compose.yml pull

and, after that finishes, see what's changed by running:

$ docker images

In my case, the answer was:

REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
postgres                 latest              405fbb2810d7        30 hours ago        265MB
grafana/grafana          latest              b9dfd6bb8484        2 days ago          149MB
iotstack_nodered         latest              5bc1358ea10f        3 days ago          540MB
postgres                 <none>              d3508eac6d79        8 days ago          265MB
influxdb                 latest              3794da419bd8        2 weeks ago         261MB
eclipse-mosquitto        latest              4af162db6b4c        5 weeks ago         8.65MB
pihole/pihole            latest              4d43d29c9890        6 weeks ago         301MB
nodered/node-red         latest              fa3bc6f20464        7 weeks ago         376MB
kunde21/gitea-arm        latest              b1320f20c065        8 weeks ago         104MB
portainer/portainer      latest              dbf28ba50432        2 months ago        62.5MB

Focus on these two lines:

postgres                 latest              405fbb2810d7        30 hours ago        265MB
postgres                 <none>              d3508eac6d79        8 days ago          265MB

The first one has just been pulled down from Dockerhub. The second one (with the "\<none>" tag) used to be the "latest" but you can't have two images tagged "latest" so the old one has had its tag removed.

That pattern (one tagged "latest" the other tagged "\<none>") tells me a couple of things:

But, that old image of postgres is the one that is still running. I switch to the new image by "upping" the stack:

$ docker-compose -f ~/IOTstack/docker-compose.yml up -d
gitea is up-to-date
Recreating postgres ... 
influxdb is up-to-date
pihole is up-to-date
grafana is up-to-date
nodered is up-to-date
mosquitto is up-to-date
portainer is up-to-date
Recreating postgres ... done

Now we can get rid of the old image. There are several ways but the one I use is:

$ docker system prune
WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all dangling images
  - all dangling build cache

Are you sure you want to continue? [y/N] y
Deleted Images:
untagged: postgres@sha256:91462e8207eadf217fe72822163277d189215b1f3792719f29352de5beb0ad53
deleted: sha256:d3508eac6d79a16ae024ce8a3d1f9e009437ed5b92f19e1157e8ef2606829d18
deleted: sha256:31576358adfa3b23ad4c4c92cfa89c8d4cbc41531d4a66044f8011549d626f98
deleted: sha256:d9289e366503f482a1a0ac0b3e7e6ef7762202cdd9e700c5e692c99a9c4a476c
deleted: sha256:52f9a963e76aa2d889c8f34ce13db095443f0c6f3195fc2406cb82301c304c00
deleted: sha256:510c689cd55b11b1d87404e368b1c905268609143f333bfd01ad4d8d1286257f
deleted: sha256:1391cff853caabbbd0b47577026f20ec7ab216790423415e346d5918112e87a5
deleted: sha256:c2e1e7ac32ef35a1779426e2372e675f74dab12672cc851f97bf1a4994a28aa7

Total reclaimed space: 179.3MB

and confirm that it has gone via:

$ docker images
REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
postgres                 latest              405fbb2810d7        30 hours ago        265MB
grafana/grafana          latest              b9dfd6bb8484        2 days ago          149MB
iotstack_nodered         latest              5bc1358ea10f        3 days ago          540MB
influxdb                 latest              3794da419bd8        2 weeks ago         261MB
eclipse-mosquitto        latest              4af162db6b4c        5 weeks ago         8.65MB
pihole/pihole            latest              4d43d29c9890        6 weeks ago         301MB
nodered/node-red         latest              fa3bc6f20464        7 weeks ago         376MB
kunde21/gitea-arm        latest              b1320f20c065        8 weeks ago         104MB
portainer/portainer      latest              dbf28ba50432        2 months ago        62.5MB

Most images/containers work like that. Node-Red is an exception where you have to remove its base image:

$ docker rmi "nodered/node-red"
$ docker-compose -f ~/IOTstack/docker-compose.yml pull
$ docker-compose -f ~/IOTstack/docker-compose.yml up --build -d

The --build applies to anything that has a Dockerfile in its services directory. You can find out what those are like this:

$ find ~/IOTstack/services -name "Dockerfile"
/home/pi/IOTstack/services/nodered/Dockerfile

Figuring out when Node-Red has been updated is a bit of a challenge. I wrote a script called "nodered_version_check" which you are welcome to use:

#!/bin/sh

LATEST=$(wget -O - -q https://raw.githubusercontent.com/node-red/node-red-docker/master/package.json | jq -r .version)
INSTALLED=$(docker inspect iotstack_nodered:latest | jq -r .[0].ContainerConfig.Labels[\"org.label-schema.version\"])

if [ "$INSTALLED" = "$LATEST" ]; then 

   echo "Node-Red is up-to-date (version $INSTALLED)"

else

/bin/cat <<-COLLECT_TEXT

    ====================================================================
    Node-Red can be updated:

        Local Version: $INSTALLED
       Remote Version: $LATEST

    Proceed like this:

       $ cd ~/IOTstack
       $ docker rmi "nodered/node-red"
       $ docker-compose pull
       $ docker-compose up --build -d

    Step 2 removes the old "base" image for Node-Red.

    Step 3 pulls any updates to other containers (and can be omitted)

    In step 4, the "--build" option causes the Dockerfile for Node-Red
    to run. That pulls down the update, builds a new local image while
    the old version is still running, then swaps new for old.
    ====================================================================

COLLECT_TEXT

fi

That script depends on wget and jq so, if it doesn't work out-of-the-box:

$ sudo apt update
$ sudo apt install -y jq wget
Paraphraser commented 3 years ago

I hope my earlier reply helped.

Please see THIS PROJECT IS DORMANT .

It is possible that your problem has been fixed on SensorsIot/IOTstack. In any case, you are more likely to get support if you migrate your installation to SensorsIot/IOTstack, find that your problem has not been fixed, and open another issue there.

If you have not already joined the Discord channel, you can often get help there too.

I'd really appreciate it if you would close this issue on gcgarner/IOTstack:

Forking the repo was the only possible way of continuing once Graham Garner "disappeared".

paolos7709 commented 3 years ago

Hello @Paraphraser. Thanks a lot for your reply. I learned a lot from it. You didn't helped me directly, but your answer helped me to understand some basics. So thanks a lot! I wanted to upgrade Portainer to version 2.0.0. The problem was, that Portainer container name has been changed from "portainer/portainer" to "portainer/portainer-ce". So All I've done at the end was just changing the container name in docker compose file and then all worked well...

` $ cat docker-compose.yml portainer: container_name: portainer image: portainer/portainer-ce restart: unless-stopped ports:

$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE oznu/homebridge no-avahi-arm32v6 73bb999e5347 41 hours ago 524MB linuxserver/plex latest 04cdc20d8f6d 5 days ago 287MB **portainer/portainer-ce latest 5526251cc61f 4 weeks ago 163MB** pihole/pihole latest 4d43d29c9890 7 weeks ago 301MB

Thanks once more for your reply and have a great day! P.

paolos7709 commented 3 years ago

This issue can be closed...