Update local Docker images

To run a local OneCX instance, Docker images with the latest version are downloaded and used. Over time, these images become outdated, meaning that even if a newer version is available, the old version is still being used locally. Check versions with script check-images.sh.

The update-images.sh script is used to renew local Docker images and removing orphaned images. It can be run from the root directory of the onecx-local-env repository.

Command to display the available options:
./update-images.sh -h

Before updating the images, it is recommended to check the current versions of the local Docker images using the script check-images.sh and stopping the local OneCX instance using stop-onecx.sh to prevent potential issues with running containers during the update process.
Run the script with the parameter -c to clean up orphaned images - can be done in combination with updating.

Available Options

The script accepts several optional options to customize its behavior. Some options can be combined.

The available options are:

-a

Update all images, ignoring name filter (if option -n is also used).
If used in combination with -c then all orphaned images and stopped containers are removed.

-c

Cleaned up orphaned images which are tagged with <none> or with status Exited.
Can be used in combination with -a (all images are affected) or with -n (only images matching the name filter are affected).
Basically, the deletion is only possible if the image is not in use. If so then stop the appropriate container first and try again.

-h

Displays help information about the script and its available options. If used then all other options are ignored.

-n <text>

Name filter, update images which have <text> into image name

Examples

Update Traefik Image

The Docker which have traefik in image name are pulled from remote registry and updated locally. In case some orphaned images are found then these are removed too.

./update-images.sh  -n traefik -c
script update images.sh traefik updated
Figure 1. Successful update with name filter and cleanup

Cleanup only

Started without any name filter will remove all orphaned images. No additional confirmation is required.

script check images.sh none images
Figure 2. Excerpt from the list of orphaned images
./update-images.sh  -c

The deletion is only possible if the image is not in use. If so then stop the appropriate container first and try again.

script update images.sh rm image failed
Figure 3. Image deletion failed
script update images.sh rm image successful
Figure 4. Image deletion successful after stopping the container

Update all images and cleanup

With option -a all images are updated, ignoring name filter. With option -c all orphaned images are removed. No additional confirmation is required.

./update-images.sh  -a -c