0

I have a Debian docker. In one line I define an alias in Dockerfile:

RUN echo alias Kill="ps -ef | grep 'dotnet' | grep -v grep | awk '{print $2}' | xargs -r kill -9" >> /etc/bash.bashrc

And when I build this docker image and run it, I can verify the line is appended to the /etc/bash.bashrc file.

However, when I type Kill I get:

bash: Kill: command not found

What do I do wrong here?

4
  • 1
    What shell is your docker image running? Is it bash or is it maybe sh? Does it work as expected if you add it to /etc/profile instead?
    – terdon
    Commented May 25, 2022 at 8:53
  • That will output alias Kill=ps -ef | grep .... to the file, and that will fail since the lack of quoting means -ef will be seen as options to alias, which doesn't understand them
    – muru
    Commented May 25, 2022 at 9:50
  • @terdon, it's bash. I have not tested the /etc/profile. But doesn't it load /etc/bash.bashrc? Commented May 25, 2022 at 9:58
  • @muru, What should I do to preserve double quotes? Commented May 25, 2022 at 9:59

0

You must log in to answer this question.

Browse other questions tagged .