How do I run a docker image as a container?

0 votes
I am new to Docker. I have built a docker image from a dockerfile.The image was built successfully, but what do I do with it? Shouldn't it be able to run as a container?   Probably I am missing some very basic thing.

Can anyone help me with this?

Thanks.
Sep 7, 2018 in Docker by shubham
• 6,890 points

retagged Sep 7, 2018 by shubham 88 views

2 answers to this question.

0 votes

You can run an image depends on whether you gave the image a tag/name or not.

$ docker images
root@dockertest:~# docker images
REPOSITORY          TAG                 ID                  CREATED             SIZE
ubuntu              12.04               8dbd9e392a96        4 months ago        131.5 MB (virtual 131.5 MB)

With a name for e.g. -  in this case Ubuntu :

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

or you can run it by just using the ID:

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

I hope it would be helpful for you.

answered Sep 7, 2018 by Damon Salvatore
• 5,510 points
0 votes

You could probably follow these steps :

  1. $ docker images

    you will get list of all local docker images with tags specified.

  2. $ docker run image_name:tag_name

    If you didn't specify tag_name it will automatically run image with 'latest' tag.

    Instead of image_name you can also specify Image Id (no tag_name).

answered Aug 9 by Sirajul
• 25,220 points

Related Questions In Docker

0 votes
1 answer
+1 vote
11 answers
0 votes
1 answer

How do I get into a Docker container?

docker attach will let you connect to your ...READ MORE

answered Aug 10, 2018 in Docker by Kalgi
• 40,440 points
59 views
0 votes
1 answer

What is a docker file? How do I create a docker image with dockerfile?

 A Dockerfile is a script/text configuration file that contains ...READ MORE

answered Jun 7 in Docker by Sirajul
• 25,220 points
303 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How do I copy a file from docker container to host?

Here is a way which you can ...READ MORE

answered Aug 27, 2018 in Docker by Damon Salvatore
• 5,510 points
2,396 views
0 votes
2 answers

How do I force Docker for a clean build of an image ?

You could try this inorder to clean ...READ MORE

answered Aug 6 in Docker by Sirajul
• 25,220 points
1,010 views