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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With