I recently upgraded one of our docker containers. I now see both the old and new versions. Is there anything I must do to remove the old version?
Could you provide more details? How do you run your containers? Where? (docker run, docker-compose, Docker Swarm, Kubernetes, ā¦) How did you upgrade? How do you see the old version?
Hi, thank you for responding!
This is a 4 node docker swarm.
Did docker pull to download latest version.
then: docker service update --image --force --update-parallelism 1
That is the task history. A limited number of previous containers are kept when you update a service. You can delete them with docker container rm
or run docker swarm update --task-history-limit 0
to disable this funtionality. The next update will then remove the old containers. But I think it can be useful when you update a service and something goes wrong. You can roll back and keep not just the previous configuration but the previous container. The stopped container will run again and the new version will be stopped.
ta@ta-mb ī° ~ ī°
Ā» docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
044a16fcf4b0 httpd:2.4 "httpd-foreground" About a minute ago Up About a minute 80/tcp httpd.1.m9hc3a4r5xi2m01s4sl7d00ig
0f054bca58d1 httpd:2.4 "httpd-foreground" 8 minutes ago Exited (0) About a minute ago httpd.1.f3xlnlnqg095zpus6rzs9vyzh
ta@ta-mb ī° ~ ī°
Ā» docker service rollback httpd
httpd
rollback: manually requested rollback
overall progress: rolling back update: 1 out of 1 tasks
1/1: running [> ]
verify: Service converged
ta@ta-mb ī° ~ ī°
Ā» docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c05d2205173d httpd:2.4 "httpd-foreground" 12 seconds ago Up 7 seconds 80/tcp httpd.1.55m1syhjrc9bx16ja3urosvue
044a16fcf4b0 httpd:2.4 "httpd-foreground" 2 minutes ago Exited (0) 8 seconds ago httpd.1.m9hc3a4r5xi2m01s4sl7d00ig
ta@ta-mb ī° ~ ī°
Ā» docker service rollback httpd
httpd
rollback: manually requested rollback
overall progress: rolling back update: 1 out of 1 tasks
1/1: running [> ]
verify: Service converged
ta@ta-mb ī° ~ ī°
Ā» docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1b5f100d870e httpd:2.4 "httpd-foreground" 15 seconds ago Up 9 seconds 80/tcp httpd.1.i672ukc53x3pnvkfscr4fyq84
c05d2205173d httpd:2.4 "httpd-foreground" About a minute ago Exited (0) 10 seconds ago httpd.1.55m1syhjrc9bx16ja3urosvue
PS.: Since I finally understand what you wanted to know, I changed the topic title. Please donāt create a topic with such a general title that doesnāt say anithing about your problem.
The āps -aā shows old containers. In my case, ādocker psā and no " -a " shows old and new versions of the container.
ps -a
? Do you mean docker ps -a
? That shows every container even the stopped containers. docker ps
wuthout -a
shows only the running containers. If it works diffferently for you, that must be a bug.
How much should I put the value for task-history-limit
for having a time rollback, I donāt want a pile of unused containers, just a one-time rollback.
I am using a compose file to create a docker stack, every time I update the stack using the command docker stack deploy -f compose.yaml
, it successfully updated the container but then I had an untagged image on my server, like -
ravadevops/ravaai_llm_server <none> 587e1e6f3b1e 23 minutes ago 7.22GB
ravadevops/ravaai_llm_server main d7b467d3b77c 42 hours ago 7.22GB
I am using only main tag image in my stack
I guess as many as you need.
Can happen if you also build a new image whihc can be caused by any change on the filesystem that affects the image layers.
ok, how can I resolve the untagged image issue
If you rebuild an image with the same tag, you will untag the original image. Use a .dockerignore file and copy files only which have to be copied so unnecessary files will not invalid the image layers. You can also run docker image prune
to delete unused and untagged (dangling) images if you already have those.
Swarm does not really care for tags when scheduling tasks, it aims for the image digest, as a deployed swarm task should always base on the same exact image, regardless on which nodes it gets (re-) started.
Actually none of the images pulled from swarm services have tags on my hosts. Only the ones build on the host, or started with docker compose
or docker run
Hello @illllm
Im facing the same issue, can you help me to resolve.
thanks