-1

Error : 'll' is not recognized as an internal or external command, operable program or batch file.

I'm getting this error when trying to get detailed information about files and directories in present working directory, I'm using cmd.

My dockerfile containes below code:

FROM ubuntu

MAINTAINER my name <my email address>

RUN apt-get update

CMD ["echo","Hello World...! from my first docker image"]

I'm fairly new with docker and I've tried everything mentioned on below link but nothing worked for me. Linux command 'll' is not working

Please if someone could help.Thanks.

Omkar C.
  • 755
  • 8
  • 21
  • Can you include your image's Dockerfile, or the script you're trying to run, in the question? `ll` isn't a standard Unix command; are you thinking of `ls -l`? Or the `||` operator? – David Maze Jun 11 '20 at 23:13
  • Hi David, I've edited my question please have a look. Also i suspect ll is an alias of `ls -l` i tried that as well but getting same error. – Omkar C. Jun 11 '20 at 23:29
  • Docker images don't generally run shell dotfiles, if you're expecting that to provide an alias. – David Maze Jun 11 '20 at 23:31
  • Then what should be used to provide a detailed information on whats inside the file and the author of file? – Omkar C. Jun 11 '20 at 23:33

1 Answers1

1

ll is an alias(shorthand) for ls -alF as specified in the same SO question that has been pointed out. In Linux, you can use the alias to shorten any command. The format of alias is alias_name='<full command>'.

Some Linux releases come pre-loaded with a set of default aliases like alias rm='rm -i', mv='mv -i'. ll is one among them. If you are getting such error then you need to add alias ll='ls -alF'.

Now the problem is where to add?
Everyone will suggest putting the alias in ~/.bashrc. But this file will be read-only if you use the bash shell. Hence there is always a chance that it might be missed out. You need to put it in a place which will be always(most likely) be read.

I agree that most people will suggest you add it to /etc/profile but here you are not supposed to make changes unless you know what you are doing. But you can put this kind of workarounds as a small shell script and put it under /etc/profile.d with *.sh extension as this directory is always read in almost all shells.

So the solution is you need to create a file with sh extension containing the alias and put it in /etc/profile.d/.

Applying all these in your Dockerfile it can be rewritten as

FROM ubuntu
MAINTAINER my name <my email address>
RUN echo "alias ll='ls -alF'" > /etc/profile.d/alias.sh && apt-get update
CMD ["echo","Hello World...! from my first docker image"]

Note: It seems alpine images don't read /etc/profile.d by default hence follow this in case if you use it.

Mani
  • 5,401
  • 1
  • 30
  • 51