-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Comments
had the same issue, this fixed it |
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 So after unzipping the getting-started tutorial we have something like d:\getting-started\app So |
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:
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 |
@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. |
|
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: 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:
|
I'm unable to get through the tutorial and am getting the above errors.
Specifically, I am trying to run
It builds successfully, gives me an ID, then exits. Upon inspecting the container, I see the following:
However, when I type ls in my console, I see:
I'm pretty new to this, so forgive me if I am missing something really basic. Any advice? |
Hi @MSoup , my working directory is so what I did is this command works fine for me |
Adding the |
According to previous comment, the issue is that we don't run docker in
My error:
And I also try add My command :
My error:
My computer is mac. This is my problem. If you have any idea, please tell me. Thanks |
I still had issue after using following code/command. The container exists straight away. Tried both syntax from @bseth15 First: 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 No errors seen when I run the above code/command (FIRST:) , but still container exists with Exit(1). 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. This syntax helped in my case: |
May we have the Container logs when you try this? Logs will help. |
Hi @iajayprajapati5, Adding :/app to the directory fixed this for me. Thank you! |
its kinda weird in my case I thougth that |
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." |
Hello I am new to Docker.
But when I see logs for this container: Then I try it with cd app command which also not works. $ docker logs 1cf51da2cf2b473209a779876e76b78e58e365073ca9061d4243f42bda7c81fc I am using Docker Toolbox and Windows 7 OS. |
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. Hope it helps |
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.
|
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"" |
@ben-xx Actually I am within the app directory, but it does not work for me:
Does anyone have a hint? Thanks in advance! :) (Windows 11, WSL 2, Docker 4.4.4, all up-2-date) |
@fbayer Not sure if this is the issue but your |
@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:
But I'm also curios about the Edit:
Edit 2: Also tried it in Windows' Command Prompt:
|
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.
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.
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. :( |
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: Working: 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. |
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: 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. |
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. |
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 |
Thank you very much.
On Jul 20, 2022, at 17:27, Russ ***@***.***> wrote:
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, the you only need to run docker compose up -d and it should work as expected.
—
Reply to this email directly, view it on GitHub<#76 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABGNE3JGE2253KFGVA4GVGDVVCKNHANCNFSM4PW3355A>.
You are receiving this because you commented.Message ID: ***@***.***>
|
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?! |
if someone is still having problem then my problem was in absolute path having something like |
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 |
I was having an issue completing the steps in Starting a Dev-Mode Container.
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:
I had to update the command in step 2 to the following:
Is this an appropriate work around?
The text was updated successfully, but these errors were encountered: