[docker] How do I run a docker instance from a DockerFile?

I finally figured out how to get docker up and running.

docker run --name my-forum-nodebb --link my-forum-redis:redis -p 80:80 -p 443:443 -p 4567:4567 -P -t -i nodebb/docker:ubuntu

I linked it to a redis instance, cool.

This is from scratch and I assume that when I created the redis instance

docker run --name my-forum-redis -d -p 6379:6379 nodebb/docker:ubuntu-redis

it pulls the image from a remote repo?

NodeBB offers a Dockerfile https://github.com/NodeBB/NodeBB/blob/master/Dockerfile I am not really quite sure how to use it. I am assuming that I can somehow create a local environment by calling this Dockerfile on my remote.

Is this correct? If so how can I create the local instance pointing to the remote?

This question is related to docker docker-machine

The answer is


Straightforward and easy solution is:

docker build .
=> ....
=> Successfully built a3e628814c67
docker run -p 3000:3000 a3e628814c67

3000 - can be any port

a3e628814c68 - hash result given by success build command

NOTE: you should be within directory that contains Dockerfile.


You cannot start a container from a Dockerfile.

The process goes like this:

Dockerfile =[docker build]=> Docker image =[docker run]=> Docker container

To start (or run) a container you need an image. To create an image you need to build the Dockerfile[1].

[1]: you can also docker import an image from a tarball or again docker load.


While other answers were usable, this really helped me, so I am putting it also here.

From the documentation:

Instead of specifying a context, you can pass a single Dockerfile in the URL or pipe the file in via STDIN. To pipe a Dockerfile from STDIN:

$ docker build - < Dockerfile

With Powershell on Windows, you can run:

Get-Content Dockerfile | docker build -

When the build is done, run command:

docker image ls

You will see something like this:

REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
<none>                     <none>              123456789        39 seconds ago      422MB

Copy your actual IMAGE ID and then run

docker run 123456789

Where the number at the end is the actual Image ID from previous step

If you do not want to remember the image id, you can tag your image by

docker tag 123456789 pavel/pavel-build

Which will tag your image as pavel/pavel-build