I have this:
> docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
edf86b00c790 mcr.microsoft.com/mssql/server:2019-CTP2.2-ubuntu "/opt/mssql/bin/sqls…" 3 weeks ago Up 6 days 0.0.0.0:3341->1433/tcp sql2019
PS C:\Users\User
> docker images ls -a
REPOSITORY TAG IMAGE ID CREATED SIZE
PS C:\Users\User
>
Trying to understand how I can be running an image that doesn't appear in the images list.
I'm running
docker --version Docker version 18.09.2, build 6247962
The correct command to list images is: docker images
Related
I believe I have tried every command recommended to remove the last few images from my sever, but I can't get rid of them.
I'm considering uninstalling docker and then remove /var/lib/docker and finally reinstalling docker.
Would that work?
Here's what I've been trying.
[root#s-app-t54 docker]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root#jenkins-agent-1 docker]# docker -v
Docker version 20.10.13, build a224086
[root#s-app-t54 docker]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root#jenkins-agent-1 docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
redis 6.0.10 621ceef7494a 14 months ago 104MB
tomcat 8.5 37bdd9cb0d0e 14 months ago 533MB
adoptopenjdk/openjdk8-openj9 jdk8u275-b01_openj9-0.23.0-alpine-slim 440045c41637 15 months ago 142MB
busybox latest dc3bacd8b5ea 16 months ago 1.23MB
redis 6 62f1d3402b78 17 months ago 104MB
httpd latest 3dd970e6b110 18 months ago 138MB
redis 5 f60d84d4d72c 20 months ago 98.3MB
stilliard/pure-ftpd latest 07037e0784e0 23 months ago 169MB
redis latest de25a81a5a0b 2 years ago 98.2MB
[root#jenkins-agent-1 docker]# docker volume ls
DRIVER VOLUME NAME
[root#jenkins-agent-1 docker]# docker rmi -f 621ceef7494a 37bdd9cb0d0e 440045c41637 \
dc3bacd8b5ea 62f1d3402b78 3dd970e6b110 f60d84d4d72c 07037e0784e0 de25a81a5a0b
Error: No such image: 621ceef7494a
Error: No such image: 37bdd9cb0d0e
Error: No such image: 440045c41637
Error: No such image: dc3bacd8b5ea
Error: No such image: 62f1d3402b78
Error: No such image: 3dd970e6b110
Error: No such image: f60d84d4d72c
Error: No such image: 07037e0784e0
Error: No such image: de25a81a5a0b
[root#jenkins-agent-1 docker]# docker system prune -a --volumes
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all volumes not used by at least one container
- all images without at least one container associated to them
- all build cache
Are you sure you want to continue? [y/N] y
Total reclaimed space: 0B
[root#jenkins-agent-1 docker]#
What will make it work will depend on what is actually causing the problem. But here are some possible solutions:
Solution 1: Restart the docker daemon:
# in case you are using Linux
sudo systemctl stop docker
sudo systemctl start docker
and then try to remove the images once again after that.
Solution 2: Try to remove the images as pointed out in this article
Solution 3: If nothing of that works, take a look at some answers replied on this other question. The accepted answer there has some side effects (read the comments related to it before doing that).
Try:- docker rmi -f $(docker image ls)
If it still says Error: No such image , then most probably your images are removed and you can verify again with: docker image ls
Edit - 1 :
I found the problem , sometimes the stopped containers store the images being used to create them.
First remove all the containers with : docker rm -f $(docker ps -a -q)
Then remove all the docker images with : docker rmi -f $(docker image ls)
I am working on single node kubernetes cluster built with kubeadm. During development, create a new docker image, but the image will be deleted immediately without permission from kubernetes garbage collection. How do I control this?
Environment:
kubeadm version: v1.17.2
kubelet version: v1.17.2
docker version: 19.03.5
Ubuntu 18.04 desktop
Linux kernel version: 4.15.0-74-generic
I created an image with the docker build command on master node, and
confirmed that the image was deleted immediately with docker
container ls -a. If I running Docker only, the images have not been
deleted. So I guess the reason for the removal was due to the
kubernetes garbage collection. – MASH 3 hours ago
Honestly, I doubt that your recently build docker image could've been deleted by kubernetes garbage collector.
I think you are confusing two concepts: image and stopped container. If you want to check your local images, you should use docker image ls command, not docker container ls -a. The last one doesn't say anything about available images and doesn't prove that any image was deleted.
It's totally normal behaviour of Docker. Please look at this example from docker docs:
We build a new docker image using following commands:
# create a directory to work in
mkdir example
cd example
# create an example file
touch somefile.txt
# build an image using the current directory as context, and a Dockerfile passed through stdin
docker build -t myimage:latest -f- . <<EOF
FROM busybox
COPY somefile.txt .
RUN cat /somefile.txt
EOF
After successful build:
Sending build context to Docker daemon 2.103kB
Step 1/3 : FROM busybox
---> 020584afccce
Step 2/3 : COPY somefile.txt .
---> 216f8119a0e6
Step 3/3 : RUN cat /somefile.txt
---> Running in 90cbaa24838c
Removing intermediate container 90cbaa24838c
---> b1e6c2284368
Successfully built b1e6c2284368
Successfully tagged myimage:latest
we run:
$ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
As you can see there's nothing there and it's totally ok.
But when you run docker image ls command instead, you'll see our recently build image:
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
myimage latest b1e6c2284368 10 seconds ago 1.22MB
I pull the tensorflow/serving in docker-for-windows Linux containers
PS C:\WINDOWS\system32> docker pull tensorflow/serving
Using default tag: latest
latest: Pulling from tensorflow/serving
Digest: sha256:f7e59a29cbc17a6b507751cddde37bccad4407c05ebf2c13b8e6ccb7d2e9affb
Status: Image is up to date for tensorflow/serving:latest
docker.io/tensorflow/serving:latest
After that for any following commands the container is not listing up
PS C:\WINDOWS\system32> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
PS C:\WINDOWS\system32> docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
PS C:\WINDOWS\system32> docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
I tried restarting docker as well, may I know how to fix it?
docker pull is pulling the image you selected
You don't have a container yet.
docker ps and the other commands you used are referring to containers.
So to run the container use:
docker run {options} image
After that you be able to see the container using docker ps
When you run docker pull tensorflow/serving the Docker image will get pulled, which can be listed using docker images command.
While docker ps, docker container ls -a, docker container ls will list running docker container. You need to run your Docker image using docker run image-name then the container will get listed using the mentioned commands.
For more info on Docker, please refer this official guide.
I have docker installed on my mac and when I do docker info I see this information:
Containers: 9
Running: 8
Paused: 0
Stopped: 1
Images: 5
But, when I run docker container ls -a or docker ps -a Then I see nothing running there.
I can see the 5 running Images when I do this: docker images -a ,
REPOSITORY TAG IMAGE ID CREATED SIZE
k8s.gcr.io/kube-apiserver-amd64 v1.10.11 e851a7aeb6e8 3 months ago 228MB
k8s.gcr.io/kube-controller-manager-amd64 v1.10.11 978cfa2028bf 3 months ago 151MB
k8s.gcr.io/kube-scheduler-amd64 v1.10.11 d2c751d562c6 3 months ago 51.2MB
k8s.gcr.io/etcd-amd64 3.1.12 52920ad46f5b 11 months ago 193MB
k8s.gcr.io/pause-amd64 3.1 da86e6ba6ca1 14 months ago 742kB
But I'm unable to delete them.
I tried doing this: docker rmi <image_id> or even this: docker rmi $(docker images -aq)
both gave errors like this:
Error response from daemon: conflict: unable to delete <image_id> (cannot be forced) - image is being used by running container <container_id>
When I try to kill one of these "running" container IDs, like this: docker kill <container_id>, I get the error:
Error response from daemon: Cannot kill container: <container_id>: Container <long_container_id> is not running
Or, if I do docker stop <container_id> then I just get back the container ID meaning the container is already stopped I guess? and yet even After that, trying to remove the images, gives the same error.
So, how do I get rid of these running "ghost" containers and images?
if you don't need the container, you can remove the container the same way you would the image
docker rm <container_id>
then after that you should have better luck removing the image
docker rmi <image_id>
or as you had to remove all images
docker rmi $(docker images -qa)
Given, on the repository I have a situation like this:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myrepo:5000/myimage latest 1c3c75da38df 3 days ago 546MB
myrepo:5000/myimage 20181130-CET183709 1c3c75da38df 3 days ago 546MB
myrepo:5000/myimage 20181126-CET191306 b143d325cd0e 7 days ago 846MB
myrepo:5000/myimage 20181122-CET190934 ccf40fb5ec0f 11 days ago 746MB
And a container running:
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
73d78cb7d34e myrepo:5000/myimage "uwsgi --plugin http…" 3 minutes ago Up 3 minutes 0.0.0.0:9090->8443/tcp heuristic_noyce
I can do:
docker exec -ti 73d7 bash --login # works - shortened container ID
but not:
docker exec -ti heuristic bash --login # fails - shortened container name
docker exec -ti heuristic_noyce bash --login # works - full container name
I can not pull a docker image by shortened digest like so:
docker pull myrepo:5000/myimage#sha256:b143d # fails - shortened image ID (digest)
Pulling a docker image by shortened tag also fails:
docker pull myrepo:5000/myimage:20181126 # fails - shortened tag
docker pull myrepo:5000/myimage:20181126-CET191306 # works - complete tag
Why not allow abbreviations for all of these?
Is there a workaround? I mean I'd understand it failing, when there were two or more tags starting with 20181126, but in cases where it is unambiguous? Where would I make a feature request for that?