-1

I have the following command that runs when run by itself (Output: Hello):

$ docker run -it --rm --name fetch_html -v ${pwd}:/usr/src/myapp -w /usr/src/myapp php:7.4-cli php 
Hello

However, I want to run it as a npm script as it's a little tedious writing the whole thing out every time:

{
  ...
  "scripts": {
    "fetch_html": "docker run -it --rm --name fetch_html -v ${pwd}:/usr/src/myapp -w /usr/src/myapp php:7.4-cli php scripts/fetch_html/cli.php"
  },
  ...

Then:

$ npm run fetch_html

But it gives me the following error:

docker: Error response from daemon: create ${pwd}: "${pwd}" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.

I've tried to change it to $(pwd) as I recall Windows and Linux having different syntax here(?). The host machine is Windows 10.

1 Answer 1

1

If you are using the Windows 10 CMD interpreter, try this:

{
  ...
  "scripts": {
    "fetch_html": "docker run -it --rm --name fetch_html -v %cd%\\:/usr/src/myapp -w /usr/src/myapp php:7.4-cli php scripts/fetch_html/cli.php"
  },
  ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.