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.
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.
I had the same problem. I ran my docker and it created a container with a specific CONTAINER_ID and I wanted to work with the same container:
first run your docker:
Then list all container you have made:
and select the container you want to work with (mine is 167ffffd6d7f15)
The specific way to run it depends on whether you gave the image a tag/name or not.
With a name (let's use ubuntu):
Without a name, just using the ID:
Please see https://docs.docker.com/engine/reference/run/ for more information.
Get the name or id of the image you would like to run, with this command:
docker images
The docker run command is used in the following way:
Below I have included the dispatch, name, publish, volume and restart options before specifying the image name or id:
--detach , -d Run container in background and print container ID --name Assign a name to the container --publish , -p Publish a container’s port(s) to the host --volume , -v Bind mount a volume --restart Restart policy to apply when a container exits
For more information please check out the official docker run reference
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
You can see your availables images using
Then you can run in detached mode
Then you can check your container is running using
docker ps give you a docker id, you can use it or just the 2/3 firsts character to gointo your container using
and you can stop it using
docker stop container_id
anddocker rm container_id
You can also run your container with -rm arguments so if you stop your container it will be automatically removed.