Run a Docker Image as a Container
I built a docker image from a dockerfile. I see the image was built successfully, but what do I do with it? Shouldn’t it be able to run as a container?
New to docker so probably a misunderstanding on my end, any help would be great.
3 Solutions collect form web for “Run a Docker Image as a Container”
The specific way to run it 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 (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 https://docs.docker.com/engine/reference/run/ for more information.
Do following steps :
$ docker images
you will get list of all local docker images with tags specified.
$ docker run image_name:tag_name
If you didn’t specify
tag_nameit will automatically run image with ‘latest’ tag.
image_nameyou can also specify Image Id (no tag_name).
Here is an example to run a webdev service in docker.
The image’s name is morrisjobke/webdav. You can pull it from dockerhub.
After you run this images,you can then access the WebDAV instance at
http://localhost:8888/webdav. Internally the folder
/var/webdav is used as WebDAV root.
You can run this container in following way:
$ docker run -d -e USERNAME=test -e PASSWORD=test -p 8888:80 morrisjobke/webdav