Issue in Docker build command

HI,

I am trying to execute the Docker build command in my Docker VM. Below is the command I have executed for Docker,

Docker build -t Dockerfile.txt .

I am noticing this error when I execute the above command in VM console.

"Uanle to prepare the context: Cannot locate Dockerfile: "absDockerfile : “/home/docker/sample/Dockerfile”

Let me know how to resolve this issue.

Regards,
Ramakumar

Hi,

Just rename Dockerfile.txt to Dockerfile and rerun the build command.

Regards

Thanks for quick response Ranjan.

As you suggested, I have changed the filename and rerun the build command.
Now I am getting different error in build command. Below are the details when I execute the build command.

Error is: repository name component must match "[a-z0-9] + (?: [ . _-][ a-z0-9] + ) * "

Regards,
Ramakumar

Could you please share your docker file ?

Hi,

Below is the content of the Dockerfile

FROM ubuntu:14.04

RUN apt-get update
RUN apt-get install software-properties-common -y
RUN add-apt-repository ppa:webupd8team/java -y
RUN apt-get update
RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
RUN apt-get install oracle-java8-installer -y
RUN apt-get install oracle-java8-set-default

Regards

Hi

move Dockerfile and related files to new location and build the image again from new location

Hi

I have only Dockerfile to run the build command. I do not have any other files with me.

Please suggest.

Ah , Forgot to mention. There is one more error in your command. You havent given the tag name.

Just try the blow command. Replace myimagename with the name for your image you are planning to give.

docker build -t myimagename .

Also make it a practice to go through the commands help to get details about each option that is being passed to the command like shown below.

docker build --help

Regards

Ranjan

I have modified the command and its working fine now.

Thank you for your guidance.

Regards

This command also should work
docker build -t Dockerfile.txt .
here image name is Dockerfile.txt

can you post the modified command ?

Yes the command will work. Please use a precise name for your image. For eamples apache, ubuntu etc.

Please follow the below guidelines

docker build -t ${IMAGE_NAME} .

  • the . (dot) specifies your Dockerfile is in the current directory.

  • ${IMAGE_NAME} image name can be like apache:0.1 where 0.1 is the version number.

  • -t refers the current user is the owner of the image

Thanks,
Amey

Hi,

Docker build wont accept image name with uppercase letters. Thats the error he faced here Issue in Docker build command

$docker build -t Dockerfile.txt .
repository name component must match "[a-z0-9]+(?:[._-][a-z0-9]+)*"

Regards

Hi Duminda,

Below is the modified command to build the image

docker build -t myjavaimage .

Regards

Thanks for your inputs Amey.

Regards