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.