Skip to content
Advertisement

How to run a dockerfile?

Found a dockerfile that want to create image and run: https://gist.github.com/matsuu/d5b4e83b3d591441f01b7be2ede774e2

Stored it in a new folder as centos-redhat-8-beta.dockerfile on my computer and tried:

docker build -t centos-redhat-8-beta .

unable to prepare context: unable to evaluate symlinks in Dockerfile path: 
lstat /Users/dnk306/docker/centos-redhat-8-beta/Dockerfile: no such file or directory

What is exact command that need to run?

Advertisement

Answer

Dockerfile is not an extension, per default the file should be called Dockerfile for the build command to use it.

If you want to use a different name, though, the option -f or flag --file can help you achieve this.

docker build -t centos-redhat-8-beta -f centos-redhat-8-beta.dockerfile .

From the documentaion:

By default the docker build command will look for a Dockerfile at the root of the build context. The -f, --file, option lets you specify the path to an alternative file to use instead. This is useful in cases where the same set of files are used for multiple builds. The path must be to a file within the build context. If a relative path is specified then it is interpreted as relative to the root of the context.

Source: https://docs.docker.com/engine/reference/commandline/build/#text-files

Advertisement