How do I run a docker image as a container

+1 vote
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?

Sep 7, 2018 in Docker by shubham
• 7,340 points

retagged Sep 7, 2018 by shubham 1,394 views

2 answers to this question.

+1 vote
Best answer

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,980 points

selected Dec 23, 2020 by MD
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, 2019 by Sirajul
• 59,230 points

Related Questions In Docker

0 votes
1 answer
+14 votes
19 answers

How can I run a ‘docker exec’ command inside a docker container?

you can run any command in a ...READ MORE

answered Dec 10, 2018 in Docker by Pramiti
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
• 52,360 points
+1 vote
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, 2019 in Docker by Sirajul
• 59,230 points
+2 votes
1 answer
+1 vote
1 answer
+1 vote
2 answers

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

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

answered Aug 28, 2018 in Docker by Damon Salvatore
• 5,980 points
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, 2019 in Docker by Sirajul
• 59,230 points
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP