skip to Main Content

When enter the command in powershell I get this error

“invalid argument “Dockerfile2**” for “-t, –tag” flag: invalid reference format: repository name must be lowercase

See docker build --help.

The Dockerfile I created is in word but I saved it as a plain text.

This is what I typed in my Dockerfile.

FROM centos:7    
ENV container docker    
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == 

systemd-tmpfiles-setup.service ] || rm -f $i; done); 

rm -f /lib/systemd/system/multi-user.target.wants/*;

rm -f /etc/systemd/system/*.wants/*;

rm -f /lib/systemd/system/local-fs.target.wants/*; 

rm -f /lib/systemd/system/sockets.target.wants/*udev*; 

rm -f /lib/systemd/system/sockets.target.wants/*initctl*; 

rm -f /lib/systemd/system/basic.target.wants/*;

rm -f /lib/systemd/system/anaconda.target.wants/*;

VOLUME [ "/sys/fs/cgroup" ]    
CMD ["/usr/sbin/init"]

3

Answers


  1. You are tagging your docker image as “Dockerfile2”.
    You can’t use the Upper case letter for tagging your docker file.
    change -t parameter from “Dockerfile2” to “dockerfile2” while building docker image.

    Login or Signup to reply.
  2. Based off the error message, when naming tags, you have to have them in lowercase.

    Try changing “Dockerfile2” in your command to the all lowercase: “dockerfile2”

    Login or Signup to reply.
  3. Please do the following in order to be able to build it successfully using Powershell:

    • First check Docker is installed on your system by entering “docker –version” command in your powershell. If you see your docker version, you are good to go, otherwise install docker properly.
    • Create a simple text (not word document etc.) file called Dockerfile (if you use other file names you will have to specify the file name with -f option)
    • Paste your dockerfile entries in it and save the file
    • In your powershell, go the path that includes your Dockerfile and run “docker build -t .”
    • check your new image by running “docker image ls”

    In my environment, your file was built successfully but there was a warning regarding one of your command in your Dockerfile entries:

    [WARNING]: Empty continuation line found in:
    RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in ; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); rm -f /lib/systemd/system/multi-usemd-tr.target.wants/;rm -f /etc/systemd/system/.wants/;rm -f /lib/systemd/system/local-.getmpfiles-setup.servifs.target.wants/; rm -f /lib/systemd/system/sockets.target.wants/udev; rm -f /lib/..wa/systemd/system/.wa.wants/;rm -f /lib/systemd/system/anaconda.target.wants/*; tm/sts.target.wants/ude
    [WARNING]: Empty continuation lines will become errors in a future release.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search