Updating the custom site "online store"
This will describe the process of updating the site "online store" in case a newer version is released.
Step 1 — Stopping docker compose
You need to stop the running containers with the command:
sudo docker compose stop
It should be noted that the commands 'sudo docker compose up -d' and 'sudo docker compose stop' must be executed from the directory where this file is located! That is, you need to physically be in the directory where the docker-compose.yml file was created.
Step 2 — Removing the old container
To display the list of existing containers, you need to execute the command:
sudo docker ps -a
A list of the containers you have will be displayed:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
877badd10cb5 internetshop "dotnet InternetShop…" 2 hours ago Up 36 seconds 443/tcp, 127.0.0.1:5000->80/tcp internetshop
e8d2c2a6297b postgres:16 "docker-entrypoint.s…" 2 hours ago Up 36 seconds 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp app_postgres_internetshop
You need to find a container whose name contains "internetshop", where the first column is the unique container ID, which we will need to delete this container using the command below. You do not need to enter the entire ID; it is sufficient to enter the first 2 or 3 digits that start the container ID:
sudo docker rm 877
Step 3 — Deleting the old container image
After deleting the container, you need to delete the image from which it was created. To view the available images, you need to execute the command:
sudo docker images
A list of the available container images will be displayed:
REPOSITORY TAG IMAGE ID CREATED SIZE
internetshop latest dc5c5fedaf2d 7 days ago 502MB
postgres 16 4cb9910d1a8e 11 days ago 432MB
You need to find the image whose name contains "internetshop" and remember the first 3 digits of its ID. Execute the following command to delete the container image:
sudo docker rmi dc5
Step 4 — Downloading and installing the new version of the application
After deleting the old container and the old image of the application container, you can run the command:
sudo docker compose up -d
After starting docker compose, it will download the latest version of the application "online store", since we deleted the old version of the application, while the database container will not be downloaded again, as we did not delete it. Thus, we have completed the software update.