Following the docker/getting-started tutorial and ...
# docker
j
Following the docker/getting-started tutorial and doing fine till I hit binding. I've tried the example commands on my Windows 10 machine for both windows cmd cli and powershell. In both cases I get a silent fail and examining the logs see that it can't find the package.json file in the root of the App folder. Any suggestions for debugging? I can see the package.json in my local directory that I'm trying to bind, so wondering if the App folder contents not getting copied over, or the json is somehow blocked... This is my first foray into Docker, having used Virtual Box in the past...
b
In my experience, if your directory mappings are invalid, they will just be ignored.
show us exactly how you're starting your docker container
And as an easy debugging step, start it, overriding the entry point command to
bash
or
sh
depending on your base OS and then just cd into your app folder to see what's actually there.
@JTDavis
j
Copy code
docker run -dp 3000:3000 \
    -w /app -v "$(pwd):/app" \
    node:12-alpine \
    sh -c "yarn install && yarn run dev"
where app is the example app the docker official documentation has you download
b
Isn't that going to run the
yarn install
in the root dir of the container?
oh wait, I see your
-w
command
So, for starters, change the command to
Copy code
docker run -dp 3000:3000 \
    -w /app -v "$(pwd):/app" \
    node:12-alpine \
    sh -c "ls -la"
and see what's in there
Also, what OS are you on? I'm not familiar with
$(pwd)
having the parens like that
Normally in bash, it's just
$PWD
assuming you have an env var of that name
or I often time see
Copy code
`pwd`
if you want an expansion that has the output of the
pwd
command
j
I'll close the windows command and open GIT Bash for a bash shell.
I'm on windows 10 with the WLS installed but normally working in Windows CMD
b
Mabey you can just back all the way up and run
Copy code
echo "$(pwd)"
to see if that even has what you expect 🙂
j
Big nothing
b
??
Meaning, it outputs an empty string?
j
SO I'll try actually putting in the path into the script which bash says is /c/workspace/app and try the script
b
Yes, try hard coding it first
Then, back up and figure out what you need to grab the current working directory correctly
It's probably a "feature" not a "bug", but really annoys me when Docker just silently ignores invalid paths
j
Oh, it complained this time:
Copy code
$ docker run -dp 3000:3000 -w /app -v "/c/workspace/app:/app" node:12-alpine sh -c "ls -la"
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'.
I don't know where it got the GIT path, I haven't GIT inited the folder, just unzipped it after download from docker.com
b
Not sure about that-- it seems you have an issue with WSL and translating paths. I'm not familiar enough with WSL to know how that works
Your command doesn't reference
C:/
anywhere so I don't know at what point that is coming into play
j
OK, I'll poke at it some more, see if Docker themselves have a forum I can root around in. Thanks, muchas gracias!
Got it to complain about EXTRA string... and finally got it. the -v option only wanted the path to the directory to map, did not want the :app to tell it what to map to.
Aaand, logging shows that Yarn ran and couldn't find the package.json. Now I get to learn how to look at a volumes contents...
t
you need to run it from wsl not windows