Run a Docker image as a container

boom picture boom · Aug 28, 2013 · Viewed 942.1k times · Source

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?

Answer

Andy picture Andy · Aug 28, 2013

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)

With a name (let's use Ubuntu):

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

Without a name, just using the ID:

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

Please see Docker run reference for more information.