简体   繁体   English

“docker exec”和“docker start”无法找到容器

[英]"docker exec" and "docker start" fails to find container

I'm new to docker and created an image from a repository that includes a " dockerfile ".我是docker 的新手,并从包含“ dockerfile ”的存储库创建了一个图像。 The build process ended successfully generating an image ID of 295e7c040cc2.构建过程成功结束,生成了一个 295e7c040cc2 的镜像 ID。 When I try to run " docker exec -it 295e7c040cc2 /bin/bash ", I get an error:当我尝试运行“ docker exec -it 295e7c040cc2 /bin/bash ”时,出现错误:

Error: No such container: 295e7c040cc2

Running "docker images" shows that the image exists.运行“docker images”显示镜像存在。

Why is this happening?为什么会这样?

You need to run your image你需要运行你的图像

docker run -it --entrypoint=/bin/bash 295e7c040cc2 

docker run is a wrapper for docker create and docker start and instantiates a new container from your image and starts it for you. docker rundocker createdocker start的包装器,它从您的图像实例化一个新容器并为您启动它。

docker exec , on the other hand, executes the specified code in a running container.另一方面, docker exec在正在运行的容器中执行指定的代码。


More info can be found here更多信息可以在这里找到

295e7c040cc2 is docker image ID , it's not container ID. 295e7c040cc2295e7c040cc2镜像 ID,不是容器 ID。 First create container from docker image.首先从 docker 镜像创建容器。

More reference:更多参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM