0

I have a Dockerfile with ENTRYPOINT ["/bin/bash", "--login", "-c"].

I am having trouble with triple-quoting.

None of the following commands to Docker work:

"echo 'New York\\\'s Finest'"
"echo 'New York\\'s Finest'"
"echo 'New York\'s Finest'"
'echo "New York\\\'s Finest"'
'echo "New York\\'s Finest"'
'echo "New York\'s Finest"'

Assuming that I need to quote the command, and there is a filename with a single quote in it that is an argument to the command, how do I resolve this?

Joseph Turian
  • 15,430
  • 14
  • 47
  • 62
  • Can you delete this `ENTRYPOINT` line entirely? It doesn't seem to be necessary here, but it forces the `CMD` to be packed into a single shell word, which introduces the quoting problem you're asking about. – David Maze Jan 12 '23 at 14:32

2 Answers2

2

How about this?

"echo \"New York's Finest\""
oguz ismail
  • 1
  • 16
  • 47
  • 69
0

in general your issue is with the escaping in the bash command:

please see explenation at: How to escape single quotes within single quoted strings

and in the dockerfile you will need to get:

ENTRYPOINT ["/bin/bash", "--login", "-c", "'echo "new york'"'"'s finest "'"]

hope this reolve it for you.

A.R.
  • 1