lavie / runlike

Given an existing docker container, prints the command line necessary to run a copy of it.
Other
1.99k stars 118 forks source link

doesn't work when docker run cmd args contain single quotes #111

Open wxl374 opened 1 year ago

wxl374 commented 1 year ago

docker inspect:

[
    {
        "Id": "*****",
        "Created": "2017-03-21T07:43:54.073781336Z",
        "Path": "/bin/sh",
        "Args": [
            "-c",
            "java   -Dnexus-work=${SONATYPE_WORK} -Dnexus-webapp-context-path=${CONTEXT_PATH}   -Xms${MIN_HEAP} -Xmx${MAX_HEAP}   -cp 'conf/:lib/*'   ${JAVA_OPTS}   org.sonatype.nexus.bootstrap.Launcher ${LAUNCHER_CONF}"
        ],
......

running runlike get:

docker run ***** /bin/sh -c 'java -Dnexus-work=${SONATYPE_WORK} -Dnexus-webapp-context-path=${CONTEXT_PATH} -Xms${MIN_HEAP} -Xmx${MAX_HEAP} -cp \'conf/:lib/*\' ${JAVA_OPTS} org.sonatype.nexus.bootstrap.Launcher ${LAUNCHER_CONF}'

but single quote cannot inside single quotes https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Single-Quotes

use '"'"' instead of \' worked https://stackoverflow.com/questions/1250079/how-to-escape-single-quotes-within-single-quoted-strings