Quote volume mapping and use pwd

Signed-off-by: Stefan Scherer <stefan.scherer@docker.com>
This commit is contained in:
Stefan Scherer
2020-07-15 08:45:25 +02:00
parent f77065be98
commit a33ed89ab3
3 changed files with 8 additions and 8 deletions

View File

@@ -40,7 +40,7 @@ So, let's do it!
```bash
docker run -dp 3000:3000 \
-w /app -v ${PWD}:/app \
-w /app -v "$(pwd):/app" \
node:12-alpine \
sh -c "yarn install && yarn run dev"
```
@@ -49,14 +49,14 @@ So, let's do it!
```powershell
docker run -dp 3000:3000 `
-w /app -v ${PWD}:/app `
-w /app -v "$(pwd):/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 "working directory" or the current directory that the command will run from
- `-v ${PWD}:/app` - bind mount the current directory from the host in the container into the `/app` directory
- `-v "$(pwd):/app"` - bind mount the current directory from the host in the container into the `/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`,