Docker Community Forums

Share and learn in the Docker community.

Issue in Docker build command


(Ramakumar) #1

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


(Ranjandas) #2

Hi,

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

Regards


(Ramakumar) #3

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


(Ameyrk) #4

Could you please share your docker file ?


(Ramakumar) #5

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


(Duminda) #6

Hi

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


(Ramakumar) #7

Hi

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

Please suggest.


(Ranjandas) #8

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


(Ramakumar) #9

Ranjan

I have modified the command and its working fine now.

Thank you for your guidance.

Regards


(Duminda) #10

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

can you post the modified command ?


(Ameyrk) #11

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


(Ranjandas) #12

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


(Ramakumar) #13

Hi Duminda,

Below is the modified command to build the image

docker build -t myjavaimage .

Regards


(Ramakumar) #14

Thanks for your inputs Amey.

Regards