Issue running docker with command parameter using NPM scriptshow to execute powershell ps1 scripts from package.json “scripts”?Run a Docker Image as a ContainerHow do I run a command on an already existing Docker container?Node Docker Container - Pulls from Git Repo for Node App Source Upon RunningDocker can't exec init scripts while run Docker start commandStart script missing error when running npm startuse docker exec in bash scriptdocker entrypoint running bash script gets “permission denied”Docker make .sh executable and run itHow to run the docker commands from python?Running `docker run` from bash script fails. Command does not fail on Command Line

Is Sanskrit really the mother of all languages?

Entering the US with dual citizenship but US passport is long expired?

What exactly is Apple Cider

Is this ram compatible with iMac 27"?

Would a character take damage when surrounded by, but not in, flames?

Problem with ls inside bash script

How is the phase of 120V AC established in a North American home?

What's the biggest difference between these two photos?

Why does low tire pressure decrease fuel economy?

Why are UK MPs allowed to abstain (but it counts as a no)?

Leaving the USA for 10 yrs when you have asylum

How can I hint that my character isn't real?

Could someone please explain what this inline #define assembly is doing?

intensity color with custom ray tracing

Bit floating sequence

What is the purpose of the rotating plate in front of the lock?

Electric shock from pedals and guitar. Jacks too long?

Short story: Interstellar inspector senses "off" nature of planet hiding aggressive culture

How do you say "to hell with everything" in French?

Can you pop microwave popcorn on a stove?

Examples where "thin + thin = nice and thick"

Why is it that I have to play this note on the piano as A sharp?

How to restrain your dragon?

Template default argument loses its reference type



Issue running docker with command parameter using NPM scripts


how to execute powershell ps1 scripts from package.json “scripts”?Run a Docker Image as a ContainerHow do I run a command on an already existing Docker container?Node Docker Container - Pulls from Git Repo for Node App Source Upon RunningDocker can't exec init scripts while run Docker start commandStart script missing error when running npm startuse docker exec in bash scriptdocker entrypoint running bash script gets “permission denied”Docker make .sh executable and run itHow to run the docker commands from python?Running `docker run` from bash script fails. Command does not fail on Command Line






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I've got a repo with some NPM convenience scripts to run some basic docker commands:



 "scripts": 
"build": "docker build -t myreadyapi --build-arg LICENSE_SERVER=1.1.1.1 .",
"prestart": "npm run build",
"start": "docker run -p 8089:8088 myreadyapi",
"debug": "docker exec -it $(docker ps -a -q --filter ancestor=myreadyapi) /bin/bash",
"stop": "docker rm $(docker stop $(docker ps -a -q --filter ancestor=myreadyapi))"



npm run build and npm run start work, but npm run debug and npm run stop cause an error:




Error: No such container: $(docker




Note: running this from Windows 10 PowerShell console.



The error happens for any docker script that has a command parameter (i.e. docker ... $(docker ...)).



Has anyone encountered this before and knows how to fix this?



Cheers.










share|improve this question






























    1















    I've got a repo with some NPM convenience scripts to run some basic docker commands:



     "scripts": 
    "build": "docker build -t myreadyapi --build-arg LICENSE_SERVER=1.1.1.1 .",
    "prestart": "npm run build",
    "start": "docker run -p 8089:8088 myreadyapi",
    "debug": "docker exec -it $(docker ps -a -q --filter ancestor=myreadyapi) /bin/bash",
    "stop": "docker rm $(docker stop $(docker ps -a -q --filter ancestor=myreadyapi))"



    npm run build and npm run start work, but npm run debug and npm run stop cause an error:




    Error: No such container: $(docker




    Note: running this from Windows 10 PowerShell console.



    The error happens for any docker script that has a command parameter (i.e. docker ... $(docker ...)).



    Has anyone encountered this before and knows how to fix this?



    Cheers.










    share|improve this question


























      1












      1








      1








      I've got a repo with some NPM convenience scripts to run some basic docker commands:



       "scripts": 
      "build": "docker build -t myreadyapi --build-arg LICENSE_SERVER=1.1.1.1 .",
      "prestart": "npm run build",
      "start": "docker run -p 8089:8088 myreadyapi",
      "debug": "docker exec -it $(docker ps -a -q --filter ancestor=myreadyapi) /bin/bash",
      "stop": "docker rm $(docker stop $(docker ps -a -q --filter ancestor=myreadyapi))"



      npm run build and npm run start work, but npm run debug and npm run stop cause an error:




      Error: No such container: $(docker




      Note: running this from Windows 10 PowerShell console.



      The error happens for any docker script that has a command parameter (i.e. docker ... $(docker ...)).



      Has anyone encountered this before and knows how to fix this?



      Cheers.










      share|improve this question














      I've got a repo with some NPM convenience scripts to run some basic docker commands:



       "scripts": 
      "build": "docker build -t myreadyapi --build-arg LICENSE_SERVER=1.1.1.1 .",
      "prestart": "npm run build",
      "start": "docker run -p 8089:8088 myreadyapi",
      "debug": "docker exec -it $(docker ps -a -q --filter ancestor=myreadyapi) /bin/bash",
      "stop": "docker rm $(docker stop $(docker ps -a -q --filter ancestor=myreadyapi))"



      npm run build and npm run start work, but npm run debug and npm run stop cause an error:




      Error: No such container: $(docker




      Note: running this from Windows 10 PowerShell console.



      The error happens for any docker script that has a command parameter (i.e. docker ... $(docker ...)).



      Has anyone encountered this before and knows how to fix this?



      Cheers.







      docker npm-scripts docker-command






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 28 at 6:22









      Ryan.BartschRyan.Bartsch

      2992 silver badges18 bronze badges




      2992 silver badges18 bronze badges

























          2 Answers
          2






          active

          oldest

          votes


















          0
















          It may happen that you have some stopped containers that match $(docker ps -a -q --filter ancestor=myreadyapi).

          Or no container is found with matching filter.

          One solution could be crate random container name and use that name in further commands or set ancestor system generated value.






          share|improve this answer

























          • If I run the command directly in the console it works... it's just when I run it via NPM

            – Ryan.Bartsch
            Mar 28 at 8:08











          • So, how does start work. After running the docker container, when it moves to debug does start exits. If that is the case try to change start as docker run -d -p 8089:8088 myreadyapi to run container as daemon.

            – Akash Sharma
            Mar 28 at 10:50











          • I don't think it has anything to do with the docker commands - they all work perfectly fine when run directly from the command line. The issue is when trying to run docker commands (specifically ones that have command parameters) via an NPM script e.g. 'npm run debug'.

            – Ryan.Bartsch
            Mar 28 at 21:02












          • They all work via the command line, but only build and start work via NPM. What's common in the stop and debug scripts that's causing them not to work? Command parameters is one thing... this is also highlighted in the error message - "Error: No such container: $(docker"

            – Ryan.Bartsch
            Mar 28 at 21:04



















          0
















          I was able to get this working by adding "@powershell" in front of the command. That assumes Powershell is in your path



          EG



          "docker:stop":"@powershell docker rm $(docker stop $(docker ps -a -q --filter ancestor=myreadyapi))"


          Referencing this answer






          share|improve this answer



























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );














            draft saved

            draft discarded
















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55391288%2fissue-running-docker-with-command-parameter-using-npm-scripts%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0
















            It may happen that you have some stopped containers that match $(docker ps -a -q --filter ancestor=myreadyapi).

            Or no container is found with matching filter.

            One solution could be crate random container name and use that name in further commands or set ancestor system generated value.






            share|improve this answer

























            • If I run the command directly in the console it works... it's just when I run it via NPM

              – Ryan.Bartsch
              Mar 28 at 8:08











            • So, how does start work. After running the docker container, when it moves to debug does start exits. If that is the case try to change start as docker run -d -p 8089:8088 myreadyapi to run container as daemon.

              – Akash Sharma
              Mar 28 at 10:50











            • I don't think it has anything to do with the docker commands - they all work perfectly fine when run directly from the command line. The issue is when trying to run docker commands (specifically ones that have command parameters) via an NPM script e.g. 'npm run debug'.

              – Ryan.Bartsch
              Mar 28 at 21:02












            • They all work via the command line, but only build and start work via NPM. What's common in the stop and debug scripts that's causing them not to work? Command parameters is one thing... this is also highlighted in the error message - "Error: No such container: $(docker"

              – Ryan.Bartsch
              Mar 28 at 21:04
















            0
















            It may happen that you have some stopped containers that match $(docker ps -a -q --filter ancestor=myreadyapi).

            Or no container is found with matching filter.

            One solution could be crate random container name and use that name in further commands or set ancestor system generated value.






            share|improve this answer

























            • If I run the command directly in the console it works... it's just when I run it via NPM

              – Ryan.Bartsch
              Mar 28 at 8:08











            • So, how does start work. After running the docker container, when it moves to debug does start exits. If that is the case try to change start as docker run -d -p 8089:8088 myreadyapi to run container as daemon.

              – Akash Sharma
              Mar 28 at 10:50











            • I don't think it has anything to do with the docker commands - they all work perfectly fine when run directly from the command line. The issue is when trying to run docker commands (specifically ones that have command parameters) via an NPM script e.g. 'npm run debug'.

              – Ryan.Bartsch
              Mar 28 at 21:02












            • They all work via the command line, but only build and start work via NPM. What's common in the stop and debug scripts that's causing them not to work? Command parameters is one thing... this is also highlighted in the error message - "Error: No such container: $(docker"

              – Ryan.Bartsch
              Mar 28 at 21:04














            0














            0










            0









            It may happen that you have some stopped containers that match $(docker ps -a -q --filter ancestor=myreadyapi).

            Or no container is found with matching filter.

            One solution could be crate random container name and use that name in further commands or set ancestor system generated value.






            share|improve this answer













            It may happen that you have some stopped containers that match $(docker ps -a -q --filter ancestor=myreadyapi).

            Or no container is found with matching filter.

            One solution could be crate random container name and use that name in further commands or set ancestor system generated value.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 28 at 7:59









            Akash SharmaAkash Sharma

            4542 silver badges6 bronze badges




            4542 silver badges6 bronze badges















            • If I run the command directly in the console it works... it's just when I run it via NPM

              – Ryan.Bartsch
              Mar 28 at 8:08











            • So, how does start work. After running the docker container, when it moves to debug does start exits. If that is the case try to change start as docker run -d -p 8089:8088 myreadyapi to run container as daemon.

              – Akash Sharma
              Mar 28 at 10:50











            • I don't think it has anything to do with the docker commands - they all work perfectly fine when run directly from the command line. The issue is when trying to run docker commands (specifically ones that have command parameters) via an NPM script e.g. 'npm run debug'.

              – Ryan.Bartsch
              Mar 28 at 21:02












            • They all work via the command line, but only build and start work via NPM. What's common in the stop and debug scripts that's causing them not to work? Command parameters is one thing... this is also highlighted in the error message - "Error: No such container: $(docker"

              – Ryan.Bartsch
              Mar 28 at 21:04


















            • If I run the command directly in the console it works... it's just when I run it via NPM

              – Ryan.Bartsch
              Mar 28 at 8:08











            • So, how does start work. After running the docker container, when it moves to debug does start exits. If that is the case try to change start as docker run -d -p 8089:8088 myreadyapi to run container as daemon.

              – Akash Sharma
              Mar 28 at 10:50











            • I don't think it has anything to do with the docker commands - they all work perfectly fine when run directly from the command line. The issue is when trying to run docker commands (specifically ones that have command parameters) via an NPM script e.g. 'npm run debug'.

              – Ryan.Bartsch
              Mar 28 at 21:02












            • They all work via the command line, but only build and start work via NPM. What's common in the stop and debug scripts that's causing them not to work? Command parameters is one thing... this is also highlighted in the error message - "Error: No such container: $(docker"

              – Ryan.Bartsch
              Mar 28 at 21:04

















            If I run the command directly in the console it works... it's just when I run it via NPM

            – Ryan.Bartsch
            Mar 28 at 8:08





            If I run the command directly in the console it works... it's just when I run it via NPM

            – Ryan.Bartsch
            Mar 28 at 8:08













            So, how does start work. After running the docker container, when it moves to debug does start exits. If that is the case try to change start as docker run -d -p 8089:8088 myreadyapi to run container as daemon.

            – Akash Sharma
            Mar 28 at 10:50





            So, how does start work. After running the docker container, when it moves to debug does start exits. If that is the case try to change start as docker run -d -p 8089:8088 myreadyapi to run container as daemon.

            – Akash Sharma
            Mar 28 at 10:50













            I don't think it has anything to do with the docker commands - they all work perfectly fine when run directly from the command line. The issue is when trying to run docker commands (specifically ones that have command parameters) via an NPM script e.g. 'npm run debug'.

            – Ryan.Bartsch
            Mar 28 at 21:02






            I don't think it has anything to do with the docker commands - they all work perfectly fine when run directly from the command line. The issue is when trying to run docker commands (specifically ones that have command parameters) via an NPM script e.g. 'npm run debug'.

            – Ryan.Bartsch
            Mar 28 at 21:02














            They all work via the command line, but only build and start work via NPM. What's common in the stop and debug scripts that's causing them not to work? Command parameters is one thing... this is also highlighted in the error message - "Error: No such container: $(docker"

            – Ryan.Bartsch
            Mar 28 at 21:04






            They all work via the command line, but only build and start work via NPM. What's common in the stop and debug scripts that's causing them not to work? Command parameters is one thing... this is also highlighted in the error message - "Error: No such container: $(docker"

            – Ryan.Bartsch
            Mar 28 at 21:04














            0
















            I was able to get this working by adding "@powershell" in front of the command. That assumes Powershell is in your path



            EG



            "docker:stop":"@powershell docker rm $(docker stop $(docker ps -a -q --filter ancestor=myreadyapi))"


            Referencing this answer






            share|improve this answer





























              0
















              I was able to get this working by adding "@powershell" in front of the command. That assumes Powershell is in your path



              EG



              "docker:stop":"@powershell docker rm $(docker stop $(docker ps -a -q --filter ancestor=myreadyapi))"


              Referencing this answer






              share|improve this answer



























                0














                0










                0









                I was able to get this working by adding "@powershell" in front of the command. That assumes Powershell is in your path



                EG



                "docker:stop":"@powershell docker rm $(docker stop $(docker ps -a -q --filter ancestor=myreadyapi))"


                Referencing this answer






                share|improve this answer













                I was able to get this working by adding "@powershell" in front of the command. That assumes Powershell is in your path



                EG



                "docker:stop":"@powershell docker rm $(docker stop $(docker ps -a -q --filter ancestor=myreadyapi))"


                Referencing this answer







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 9 at 14:38









                JeffJeff

                4701 gold badge4 silver badges16 bronze badges




                4701 gold badge4 silver badges16 bronze badges































                    draft saved

                    draft discarded















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55391288%2fissue-running-docker-with-command-parameter-using-npm-scripts%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript