Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Bind Mounts: error Couldn't find a package.json file in "/app" #76

Closed
bseth15 opened this issue Aug 6, 2020 · 34 comments
Closed

Comments

@bseth15
Copy link

bseth15 commented Aug 6, 2020

I was having an issue completing the steps in Starting a Dev-Mode Container.

  1. Run the following command (if you are using PowerShell then use this command):

docker run -dp 3000:3000 `
-w /app -v "$(pwd):/app" `
node:12-alpine `
sh -c "yarn install && yarn run dev"

An image ID would be output in the shell, but examining the container using Docker Desktop revealed the container had exited with the following terminal output:

yarn install v1.22.4
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.05s.
yarn run v1.22.4
error Couldn't find a package.json file in "/app"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I had to update the command in step 2 to the following:

docker run -dp 3000:3000 `
-w /app -v "$(pwd):/app" `
node:12-alpine `
sh -c "cd app && yarn install && yarn run dev"

Is this an appropriate work around?

@debugwand
Copy link

had the same issue, this fixed it

@ben-xx
Copy link

ben-xx commented Oct 1, 2020

The tutorial mentions only once early on which directory you should run commands from when starting the tutorial, so it's easy to miss.

We need to be inside the app directory.

So after unzipping the getting-started tutorial we have something like d:\getting-started\app
If running the docker run command from d:\getting-started\ you'll get the above error.

So cd into d:\getting-started\app and try the command again.

@sujirou
Copy link

sujirou commented Oct 24, 2020

hey thanks, @ben-xx ! this worked for me. only makes sense. it really was easy to miss.

just a quick one tho. i know im late to the party here but, on this command block:

docker run -dp 3000:3000 \
    -w /app -v "$(pwd):/app" \
    node:12-alpine \
    sh -c "yarn install && yarn run dev"

is it really going to make our container data persistent? like if i make changes (add some items), stop the container and create a new image, will the changes stick around? i think it won't because the data is supposed to be stored in todo.db which is at the /etc/todos directory. i tried it myself and sure enough, it didn't. im obviously missing something here :(

@ben-xx
Copy link

ben-xx commented Oct 27, 2020

@sujirou The docker command you've copy/pasted won't persist anything. If you continue further into the tutorial it shows how persistence is done using named volumes which live separate from containers and won't be deleted if you delete or stop/restart a container.

@mascomen4
Copy link

mascomen4 commented Dec 13, 2020

cd getting-started/app helped

@Franz333
Copy link

Hi,

It's not working for me..

The container exits straightaway.

At first I had to replace the quote before $(pwd) by a backslash as I was getting an error: "$(pwd)" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed.

Then I tried the workaround suggested by @bseth15 and added the cd app command but it's not working either. The container exited.

I am in "app" directory when running my commands.

Any suggestion?

@BJladika
Copy link

Hi,

It's not working for me..

The container exits straightaway.

At first I had to replace the quote before $(pwd) by a backslash as I was getting an error: "$(pwd)" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed.

Then I tried the workaround suggested by @bseth15 and added the cd app command but it's not working either. The container exited.

I am in "app" directory when running my commands.

Any suggestion?

I guess you're using Windows, which is not quite oriented with variable aka $pwd for example, so either:

  1. Open PowerShell (it supposed to support enviroment variables such as {$PWD}
  2. Write in cmd (if you're using it) the 2nd line smth like "-w /app -v FULLPATH:/app" for example "-w /app -v C:\getting-started\app/:app"

@Franz333
Copy link

Hi @BJladika,
Thanks for taking the time to help!
Yes I am using windows sorry I should have mentioned that.
In the meantime I tried the solution provided here and it worked, I will try your command too next time ;-)
#100
Big thanks

@MSoup
Copy link

MSoup commented Mar 31, 2021

I'm unable to get through the tutorial and am getting the above errors.
I'm using Windows 10 and bash on VSCode. I'm in the getting-started/app directory when I run the commands.
This is what is listed when I type pwd in my console

/c/Users/charm/OneDrive/Desktop/Solacom/getting-started/app

Specifically, I am trying to run

docker run -dp 3000:3000 -w //app -v "//c/Users/charm/OneDrive/Desktop/Solacom/getting-started:/app" node:12-alpine sh -c "yarn install && yarn run dev"

It builds successfully, gives me an ID, then exits. Upon inspecting the container, I see the following:

yarn install v1.22.5

[1/4] Resolving packages...

success Already up-to-date.

Done in 0.09s.

yarn run v1.22.5

error Couldn't find a package.json file in "/app"

info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

However, when I type ls in my console, I see:

$ ls
Dockerfile  package.json  spec  src  yarn.lock

I'm pretty new to this, so forgive me if I am missing something really basic. Any advice?

@iajayprajapati5
Copy link

Hi @MSoup ,
I am also new to docker today I faced same issue with windows 10 only,

my working directory is
E:\DockerPractice\getting-started\app

so what I did is
docker run -dp 3000:3000 -w //app -v "//e/DockerPractice/getting-started/app:/app" node:12-alpine sh -c "yarn install && yarn run dev"

this command works fine for me

@Jack-R-Long
Copy link

Adding the cd app && to sh -c "cd app && yarn install && yarn run dev" fixed the problem for me. Thank you!

@Bonnie-dot
Copy link

According to previous comment, the issue is that we don't run docker in /app. I tried many times in /app and the container will exist quickly.
My command :

docker run -dp 3000:3000 \ 
    -w /app -v "$(pwd):/app" \
    node:12-alpine \
    sh -c "yarn install && yarn run dev"

My error:

yarn install v1.22.5
Error: EPERM: operation not permitted, open '/app/package.json'
    at Object.openSync (fs.js:462:3)
    at Object.readFileSync (fs.js:364:35)
    at onUnexpectedError (/opt/yarn-v1.22.5/lib/cli.js:92554:106)
    at /opt/yarn-v1.22.5/lib/cli.js:92673:9

And I also try add cd /app in my command, and run it in this directory /getting-started-master

My command :

 docker run -dp 3000:3000 \ 
    -w /app -v "$(pwd):/app" \
    node:12-alpine \
    sh -c "cd app && yarn install && yarn run dev"

My error:

yarn install v1.22.5
Error: EPERM: operation not permitted, open '/app/app/package.json'
    at Object.openSync (fs.js:462:3)
    at Object.readFileSync (fs.js:364:35)
    at onUnexpectedError (/opt/yarn-v1.22.5/lib/cli.js:92554:106)
    at /opt/yarn-v1.22.5/lib/cli.js:92673:9

My computer is mac. This is my problem. If you have any idea, please tell me. Thanks

@gajjalaanvesh
Copy link

gajjalaanvesh commented May 21, 2021

I still had issue after using following code/command. The container exists straight away.

Tried both syntax from @bseth15

First:
docker run -dp 3000:3000 -w /app -v "$(pwd):/app"
node:12-alpine `
sh -c "yarn install && yarn run dev"

Second: NOTE: Do not us this if you are already running the command from the image working directory(/app). If you do so, it will again look for 'app' folder inside /app (lol it happened with me)

docker run -dp 3000:3000 -w /app -v "$(pwd):/app"
node:12-alpine `
sh -c "cd app && yarn install && yarn run dev"

No errors seen when I run the above code/command (FIRST:) , but still container exists with Exit(1).

docker run error1

Hmm! issue was with the ssl certificate. If you encountered this at building image phase (docker build -t getting-started .) , it is same issue. Refer below issue link for details.

#56

This syntax helped in my case:
docker run -dp 3000:3000 -w /app -v "$(pwd):/app"
node:12-alpine `
sh -c "yarn config set strict-ssl false -g && yarn install && yarn run dev"

@gajjalaanvesh
Copy link

Hi,

It's not working for me..

The container exits straightaway.

At first I had to replace the quote before $(pwd) by a backslash as I was getting an error: "$(pwd)" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed.

Then I tried the workaround suggested by @bseth15 and added the cd app command but it's not working either. The container exited.

I am in "app" directory when running my commands.

Any suggestion?

May we have the Container logs when you try this? Logs will help.
Once you run the container using the suggested syntax by @bseth15 and after container exists with Exit(1), run the following " docker container logs " and paste the details here.

@mike1125g
Copy link

Hi @iajayprajapati5,

Adding :/app to the directory fixed this for me.

Thank you!

@alfligno
Copy link

alfligno commented Jun 21, 2021

The tutorial mentions only once early on which directory you should run commands from when starting the tutorial, so it's easy to miss.

We need to be inside the app directory.

So after unzipping the getting-started tutorial we have something like d:\getting-started\app
If running the docker run command from d:\getting-started\ you'll get the above error.

So cd into d:\getting-started\app and try the command again.

its kinda weird in my case I thougth that -w which is working directory mean the current directory of the machine which is the real machine not the container itself, its kinda confusing so -w refers to the containers working directory of the container in the real sense, so the next command which is -v "$(pwd):/app". The $(pwd) link your current working directory (not the containers directory) to the containers local directory which is the /app.

@jkelley399
Copy link

I encountered essentially the same problem as reported by @bseth15 twice: (a) in Part 6, "Using bind mounts," and again Part 7, "Multi container apps." Thank you for the helpful suggestions. I would recommend changing the language in the tutorial accordingly. In Part 6, in the "Start a dev-mode container" section, I'd recommend changing "Run the following command." to read "Run the following command from the app/ directory." Similarly, in Part 7, in the "Run your app with MySQL" section, Id recommend changing "We’ll specify each of the environment variables above, as well as connect the container to our app network." to "We’ll specify each of the environment variables above, as well as connect the container to our app network. Run the following from the app/ directory."

@spandanparikh
Copy link

spandanparikh commented Nov 7, 2021

Hello I am new to Docker.
I am inside app folder and running below command:

$ docker run -dp 3000:3000
-w /app -v "$(pwd):/app"
node:12-alpine
sh -c "yarn install && yarn run dev"
6dafd7416dc6ea3ef68e910429ed3ea0881eb1ace3eb0218fb56578cac7fa033

But when I see logs for this container:
$ docker logs 6dafd7416dc6ea3ef68e910429ed3ea0881eb1ace3eb0218fb56578cac7fa033
yarn install v1.22.15
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.07s.
yarn run v1.22.15
error Couldn't find a package.json file in "/app"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Then I try it with cd app command which also not works.
Getting below errors:

$ docker logs 1cf51da2cf2b473209a779876e76b78e58e365073ca9061d4243f42bda7c81fc
sh: cd: line 1: can't cd to app: No such file or directory

I am using Docker Toolbox and Windows 7 OS.
Kindly help me I stuck totally.

@Sartoric
Copy link

yarn install v1.22.5
Error: EPERM: operation not permitted, open '/app/app/package.json'

My computer is mac. This is my problem. If you have any idea, please tell me. Thanks

Since I stumbled on the same issue today, and as there isn't an answer to it, I'm answering with my solution to this Mac issue to avoid others wasting hours as I did 😁.

I solved it checking "Security and Privacy" settings.
Ensure that both Terminal and Docker have rights to access the Download folder (or the folder you're extracting the app file)
During docker installation I probably dismissed the request for access rights on download folder, so I really missed it in the first place

Hope it helps

@JustSEddThat
Copy link

I'm unable to get through the tutorial and am getting the above errors. I'm using Windows 10 and bash on VSCode. I'm in the getting-started/app directory when I run the commands. This is what is listed when I type pwd in my console

/c/Users/charm/OneDrive/Desktop/Solacom/getting-started/app

Specifically, I am trying to run

docker run -dp 3000:3000 -w //app -v "//c/Users/charm/OneDrive/Desktop/Solacom/getting-started:/app" node:12-alpine sh -c "yarn install && yarn run dev"

It builds successfully, gives me an ID, then exits. Upon inspecting the container, I see the following:

yarn install v1.22.5

[1/4] Resolving packages...

success Already up-to-date.

Done in 0.09s.

yarn run v1.22.5

error Couldn't find a package.json file in "/app"

info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

However, when I type ls in my console, I see:

$ ls
Dockerfile  package.json  spec  src  yarn.lock

I'm pretty new to this, so forgive me if I am missing something really basic. Any advice?

Hi, I also ran into this issue in vs code using Windows 10 in bash command line.

If you haven't solved this or if someone else is in a similar situation and has not come to a resolution. I solved this little issue by using the powershell version of the suggested command in powershell.

docker run -dp 3000:3000 `
    -w /app -v "$(pwd):/app" `
    node:12-alpine `
    sh -c "yarn install && yarn run dev"

@PerThomsen
Copy link

I cd into c:\windows\user\myname\getting-started\app and run the command: "docker run -dp 3000:3000 -w /app -v "%cd%:/app" node:12-alpine sh -c "yarn install && yarn run dev""
It worked for me :)

@fbayer
Copy link

fbayer commented Feb 8, 2022

@ben-xx Actually I am within the app directory, but it does not work for me:

flo@pc MINGW64 /c/dev/docker/tutorial/getting-started/app (master)
$ ls
Dockerfile node_modules/ package.json spec/ src/ yarn.lock

flo@pc MINGW64 /c/dev/docker/tutorial/getting-started/app (master)
$ docker run -dp 3000:3000 -w //app -v "$(pwd):/app" node:12-alpine sh -c "yarn install && yarn run dev" 949e42cfc96571bc21e4ee981615be4d211038a2e457894de8a599cbee89f262

flo@pc MINGW64 /c/dev/docker/tutorial/getting-started/app (master)
$ docker logs -f 949e42cfc96571bc21e4ee981615be4d211038a2e457894de8a599cbee89f262
yarn install v1.22.17
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 0.07s.
yarn run v1.22.17
error Couldn't find a package.json file in "/app"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Does anyone have a hint? Thanks in advance! :)

(Windows 11, WSL 2, Docker 4.4.4, all up-2-date)

@ben-xx
Copy link

ben-xx commented Feb 8, 2022

@fbayer Not sure if this is the issue but your -w //app has a double // instead of single /. Could that be the issue?

@fbayer
Copy link

fbayer commented Feb 9, 2022

@ben-xx I don't think so, because I'm on Windows (11) with git bash here and if I would execute the command with only a single slash:

flo@pc MINGW64 /c/dev/docker/tutorial/getting-started/app (master)
$ ls -ltrh
total 328K
drwxr-xr-x 1 Flo 197609 0 Feb 9 07:26 node_modules/
-rw-r--r-- 1 Flo 197609 679 Feb 9 07:28 package.json
drwxr-xr-x 1 Flo 197609 0 Feb 9 07:28 spec/
drwxr-xr-x 1 Flo 197609 0 Feb 9 07:28 src/
-rw-r--r-- 1 Flo 197609 163K Feb 9 07:28 yarn.lock

flo@pc MINGW64 /c/dev/docker/tutorial/getting-started/app (master)
$ docker run -dp 3000:3000 -w /app -v "$(pwd):/app" node:12-alpine sh -c "yarn install && yarn run dev"
docker: Error response from daemon: the working directory 'C:/Program Files/Git/app' is invalid, it needs to be an absolute path.
See 'docker run --help'.

But I'm also curios about the C:/Program Files/Git/app path?!

Edit:
Just noticed that the command above (with single slash) created a new subfolder 'app;C' within /getting-started:

Flo@pc MINGW64 /c/dev/docker/tutorial/getting-started/app (master)
$ cd ..

Flo@pc MINGW64 /c/dev/docker/tutorial/getting-started (master)
$ ls -ltrh
total 33K
-rw-r--r-- 1 Flo 197609 12K Feb 8 10:08 LICENSE
-rw-r--r-- 1 Flo 197609 557 Feb 8 10:08 Jenkinsfile
-rw-r--r-- 1 Flo 197609 1.1K Feb 8 10:08 Dockerfile
-rw-r--r-- 1 Flo 197609 1.7K Feb 8 10:08 README.md
-rw-r--r-- 1 Flo 197609 179 Feb 8 10:08 docker-compose.yml
-rwxr-xr-x 1 Flo 197609 267 Feb 8 10:08 build.sh*
drwxr-xr-x 1 Flo 197609 0 Feb 8 10:08 docs/
-rw-r--r-- 1 Flo 197609 90 Feb 8 10:08 yarn.lock
-rw-r--r-- 1 Flo 197609 110 Feb 8 10:08 requirements.txt
-rw-r--r-- 1 Flo 197609 2.1K Feb 8 10:08 mkdocs.yml
drwxr-xr-x 1 Flo 197609 0 Feb 9 07:28 app/
drwxr-xr-x 1 Flo 197609 0 Feb 9 07:29 'app;C'/

Edit 2:

Also tried it in Windows' Command Prompt:

c:\dev\docker\tutorial\getting-started\app>docker run -dp 3000:3000 -w /app -v "$(pwd):/app" node:12-alpine sh -c "yarn install && yarn run dev"
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.
See 'docker run --help'.

c:\dev\docker\tutorial\getting-started\app>docker run -dp 3000:3000 -w /app -v "C:\dev\docker\tutorial\getting-started\app" node:12-alpine sh -c "yarn install && yarn run dev"
e5055c93ca421c3b1bcc677f0083ccfc9276a50470e61c3731c26ac235f73675

c:\dev\docker\tutorial\getting-started\app>docker logs -f e5055c93ca421c3b1bcc677f0083ccfc9276a50470e61c3731c26ac235f73675
yarn install v1.22.17
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 0.06s.
yarn run v1.22.17
error Couldn't find a package.json file in "/app"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

c:\dev\docker\tutorial\getting-started\app>dir
Volume in drive C has no label.
Volume Serial Number is B00B-4543

Directory of c:\dev\docker\tutorial\getting-started\app

02/09/2022 07:28 AM

.
02/09/2022 07:38 AM ..
02/09/2022 07:26 AM node_modules
02/09/2022 07:28 AM 679 package.json
02/09/2022 07:28 AM spec
02/09/2022 07:28 AM src
02/09/2022 07:28 AM 165,938 yarn.lock
2 File(s) 166,617 bytes
5 Dir(s) 52,571,279,360 bytes free

c:\dev\docker\tutorial\getting-started\app>

yuuyins added a commit to yuuyins/getting-started that referenced this issue Feb 10, 2022
If the user runs that command "from the source code folder", i.e.
`getting-started`, docker will bind-mount `getting-started` to the
container's `/app`, which leads to error
`error Couldn't find a package.json file in "/app"`. It needs to bind
`getting-started/app` instead.
pwd can be confusing, so just be explicit about the path and make the
user user substitute the path in the command themselves.
yuuyins added a commit to yuuyins/getting-started that referenced this issue Feb 12, 2022
If the user runs that command "from the source code folder", i.e.
getting-started, docker will bind-mount getting-started to the
container's /app, which leads to error
error Couldn't find a package.json file in "/app". It needs to bind
getting-started/app instead.
So, add `/app` after `pwd` for binding it instead, and be explicit to
the user to be on the source code's root directory `getting-started`
before running the command.
@kronster
Copy link

kronster commented Feb 22, 2022

If your $PWD is a mapped network drive the command will work yet yield an error since the mapping didn't work. After copying the tutorial to a local volume it worked flawlessly. Would be great if the tutorial was updated to state "Do not use a network folder for the Tutorial." :)

@fbayer
Copy link

fbayer commented Feb 22, 2022

If your $PWD is a mapped network drive the command will work yet yield an error since the mapping didn't work. After copying the tutorial to a local volume it worked flawlessly. Would be great if the tutorial was updated to state "Do not use a network folder for the Tutorial." :)

Actually I have a local volume and not a network folder, but the tutorial doesn't work for me. :(

@benkanlu
Copy link

benkanlu commented Apr 4, 2022

If you are using WSL with Ubuntu on Windows and using an Ubuntu terminal (not Powershell) , I finally was able to get it to work by not using the $(pwd) part and using the actual path in Windows. Using the '/mnt/c/temp/Downloads/app/app:/app' did not work, but specifying the Windows equivalent path 'C://temp//Downloads//app//app:/app' actually works. Not sure why but WSL won't use the correct path if you use the '/mnt/c/' or the pwd.

Not working:
docker run -dp 3000:3000 -w /app -v "/mnt/c/temp/Downloads/app/app:/app" node:12-alpine sh -c "yarn install && yarn run dev"

Working:
docker run -dp 3000:3000 -w /app -v "C://temp//Downloads//app//app:/app" node:12-alpine sh -c "yarn install && yarn run dev"

Note, I was able to get the PowerShell version command to work fine that the tutorial provided. However, I want to be exclusively in a Ubuntu shell/terminal, not Powershell/Command, so this was important to figure out if it was indeed compatible.

Hope this saves someone else some frustrations/time.

@benkanlu
Copy link

benkanlu commented Apr 6, 2022

While the above works for the 'docker run', I hit similar issues when I got to the 'docker-compose' section. Looking through this issue here microsoft/WSL#1854, I finally figured out what worked for me was the suggestion to add the following to your /etc/wsl.conf file and restart your WSL instance:
[automount]
root = /

This changes the default mount now from '/mnt/c/' to '/c' (You may have to create the /c directory, not sure since I tried the other suggestions of 'sudo mount --bind /mnt/c /c', which didn't work for me.

Anyway, the above worked for me for both 'docker run' using the provided $(pwd) example as well as for the docker-compose example later on in the tutorial. Docker-compose is more strict it seems. Cheers.

@LukeIsNull
Copy link

I'm unable to get through the tutorial and am getting the above errors. I'm using Windows 10 and bash on VSCode. I'm in the getting-started/app directory when I run the commands. This is what is listed when I type pwd in my console

/c/Users/charm/OneDrive/Desktop/Solacom/getting-started/app

Specifically, I am trying to run

docker run -dp 3000:3000 -w //app -v "//c/Users/charm/OneDrive/Desktop/Solacom/getting-started:/app" node:12-alpine sh -c "yarn install && yarn run dev"

It builds successfully, gives me an ID, then exits. Upon inspecting the container, I see the following:

yarn install v1.22.5

[1/4] Resolving packages...

success Already up-to-date.

Done in 0.09s.

yarn run v1.22.5

error Couldn't find a package.json file in "/app"

info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

However, when I type ls in my console, I see:

$ ls
Dockerfile  package.json  spec  src  yarn.lock

I'm pretty new to this, so forgive me if I am missing something really basic. Any advice?

Hi, I also ran into this issue in vs code using Windows 10 in bash command line.

If you haven't solved this or if someone else is in a similar situation and has not come to a resolution. I solved this little issue by using the powershell version of the suggested command in powershell.

docker run -dp 3000:3000 `
    -w /app -v "$(pwd):/app" `
    node:12-alpine `
    sh -c "yarn install && yarn run dev"

Hi, it still not work for me. My OS is windows 8.1 and I uses the vscode with bash terminal. For the command option "-w //app -v //f/Code/Docker/getting-started/app://app", the container exists with error "Couldn't find a package.json file in "/app"". Then I tried to run command in powershell as you said. But it prompts that /app is a invalid mode.
I'm sure the command is run in the path under getting-started/app. So is there anyway which can help me fix this issue?

@TwoFistedJustice
Copy link

TwoFistedJustice commented Jul 21, 2022

The problem originates with the tutorial itself. In step 1 it says "At the root of the app project, create a file named docker-compose.yml"

This might lead someone to put the yaml file in the root of the project, in which case we get the "cannot fine package.json" error. It won't matter whether you run docker compose from within /app or not. If you do put the yaml file in the project root then you must put "cd app" inside the command.

If you put the yaml file in /app folder itself, then you only need to run docker compose up -d and it should work as expected.

@jkelley399
Copy link

jkelley399 commented Jul 21, 2022 via email

@backup01
Copy link

Hi,
It's not working for me..
The container exits straightaway.
At first I had to replace the quote before $(pwd) by a backslash as I was getting an error: "$(pwd)" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed.
Then I tried the workaround suggested by @bseth15 and added the cd app command but it's not working either. The container exited.
I am in "app" directory when running my commands.
Any suggestion?

I guess you're using Windows, which is not quite oriented with variable aka $pwd for example, so either:

  1. Open PowerShell (it supposed to support enviroment variables such as {$PWD}
  2. Write in cmd (if you're using it) the 2nd line smth like "-w /app -v FULLPATH:/app" for example "-w /app -v C:\getting-started\app/:app"

Thank you! I have been trying to fix this for hours and don't understand, why i got the message if i'm inside the /app?!
The lesson is: never use cmd on Windows, PowerShell only.

@kimondo88
Copy link

if someone is still having problem then my problem was in absolute path having something like
//C//Users/user ->
instead making it lowercase for drive and users folder helped
//c/users/user
made a docker command work.

@BooleanType
Copy link

I had the same problem on Ubuntu 22.04. I couldn't figure out until noticed @kronster answer. The matter is that I placed the project in a /var/www/html folder. This folder is tied to the Apache server that was running. I'm assuming it was just the network folder case @kronster described. After moving my project to home dir everything worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests