将 Docker 镜像作为容器运行 [英] Run a Docker image as a container

查看:42
本文介绍了将 Docker 镜像作为容器运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

dockerfile 构建 Docker 镜像后,我看到镜像构建成功,但是我该怎么做呢?我不应该能够将它作为容器运行吗?

After building a Docker image from a dockerfile, I see the image was built successfully, but what do I do with it? Shouldn't i be able to run it as a container?

推荐答案

具体的运行方式取决于你是否给图像一个标签/名称.

The specific way to run it depends on whether you gave the image a tag/name or not.

$ docker images
REPOSITORY          TAG                 ID                  CREATED             SIZE
ubuntu              12.04               8dbd9e392a96        4 months ago        131.5 MB (virtual 131.5 MB)

带有名称(让我们使用 Ubuntu):

With a name (let's use Ubuntu):

$ docker run -i -t ubuntu:12.04 /bin/bash

没有名字,只用ID:

$ docker run -i -t 8dbd9e392a96 /bin/bash

请参阅Docker 运行参考了解更多信息.

Please see Docker run reference for more information.

这篇关于将 Docker 镜像作为容器运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆