Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a Docker image as a container

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?

like image 999
boom Avatar asked Aug 28 '13 20:08

boom


People also ask

How do I run a docker image as a container?

To run an image inside of a container, we use the docker run command. The docker run command requires one parameter and that is the image name. Let's start our image and make sure it is running correctly.

Is docker image same as docker container?

A Docker image executes code in a Docker container. You add a writable layer of core functionalities on a Docker image to create a running container. Think of a Docker container as a running image instance. You can create many containers from the same image, each with its own unique data and state.

Can I use a docker image as a VM?

Virtual machinesDocker isn't a VM technology. It doesn't simulate a machine's hardware and it doesn't include an operating system. A Docker container is not by default constrained to specific hardware limits. If Docker virtualizes anything, it virtualizes the environment in which services run, not the machine.


1 Answers

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.

like image 175
Andy Avatar answered Sep 22 '22 11:09

Andy