[英]Docker image in local computer has deleted by Kubernetes garbage collection
I am working on single node kubernetes cluster built with kubeadm.我正在研究使用 kubeadm 构建的单节点 kubernetes 集群。 During development, create a new docker image, but the image will be deleted immediately without permission from kubernetes garbage collection.
在开发过程中,创建一个新的docker镜像,但是这个镜像会在未经kubernetes垃圾收集许可的情况下被立即删除。 How do I control this?
我该如何控制?
Environment:环境:
I created an image with the
docker build
command on master node, and confirmed that the image was deleted immediately withdocker container ls -a
.我在主节点上使用
docker build
命令创建了一个镜像,并使用docker container ls -a
确认该镜像被立即删除。 If I running Docker only, the images have not been deleted.如果我只运行 Docker,图像还没有被删除。 So I guess the reason for the removal was due to the kubernetes garbage collection.
所以我想删除的原因是由于 kubernetes 垃圾收集。 – MASH 3 hours ago
– MASH 3 小时前
Honestly, I doubt that your recently build docker image could've been deleted by kubernetes garbage collector.老实说,我怀疑您最近构建的 docker 镜像可能已被 kubernetes 垃圾收集器删除。
I think you are confusing two concepts: image
and stopped container
.我认为您混淆了两个概念:
image
和stopped container
。 If you want to check your local images, you should use docker image ls
command, not docker container ls -a
.如果要检查本地映像,应使用
docker image ls
命令,而不是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 .这完全是Docker的正常行为。 Please look at this example from docker docs :
请查看docker docs中的此示例:
We build a new docker image using following commands:我们使用以下命令构建一个新的 docker 镜像:
# 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
命令时,你会看到我们最近构建的镜像:
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
myimage latest b1e6c2284368 10 seconds ago 1.22MB
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.