Skip to content

Commit

Permalink
Fix docker#76
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yuuyins committed Feb 10, 2022
1 parent 8725352 commit fb23eba
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/tutorial/using-bind-mounts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,27 @@ So, let's do it!

1. Make sure you don't have any previous `getting-started` containers running.

1. Run the following command from the source code folder. We'll explain what's going on afterwards:
1. In the following command, substitute `path/to/getting-started/app` to the respective path to `getting-started/app` on your system, and then run it. We'll explain what's going on afterwards:

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

If you are using PowerShell then use this command.
If you are using PowerShell then use this command (remember to substitute `path/to/getting-started/app`).

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

- `-dp 3000:3000` - same as before. Run in detached (background) mode and create a port mapping
- `-w /app` - sets the container's present working directory where the command will run from
- `-v "$(pwd):/app"` - bind mount (link) the host's present working directory to the container's `/app` directory
- `-v "path/to/getting-started/app:/app"` - bind mount (link) the host's `getting-started/app` directory to the container's `/app` directory
- `node:12-alpine` - the image to use. Note that this is the base image for our app from the Dockerfile
- `sh -c "yarn install && yarn run dev"` - the command. We're starting a shell using `sh` (alpine doesn't have `bash`) and
running `yarn install` to install _all_ dependencies and then running `yarn run dev`. If we look in the `package.json`,
Expand Down

0 comments on commit fb23eba

Please sign in to comment.