How to update existing images with docker-compose?

Docker containers are designed to be ephemeral. To update an existing container, you remove the old one and start a new one. Thus the process that you are following is the correct one.

You can simplify the commands to the following ones:

docker-compose up --force-recreate --build -d
docker image prune -f

You can update it using:

docker-compose pull

Now your image is updated. If you have the previous version of container running you should restart it to use the updated image:

docker-compose up --detach

up command automatically recreates container on image or configuration change.