From a33ed89ab3ca413fadeac864fa1fdce949625314 Mon Sep 17 00:00:00 2001 From: Stefan Scherer Date: Wed, 15 Jul 2020 08:45:25 +0200 Subject: [PATCH] Quote volume mapping and use pwd Signed-off-by: Stefan Scherer --- docs/tutorial/multi-container-apps/index.md | 4 ++-- docs/tutorial/using-bind-mounts/index.md | 6 +++--- docs/tutorial/using-docker-compose/index.md | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/tutorial/multi-container-apps/index.md b/docs/tutorial/multi-container-apps/index.md index 59d2c49..d400835 100644 --- a/docs/tutorial/multi-container-apps/index.md +++ b/docs/tutorial/multi-container-apps/index.md @@ -180,7 +180,7 @@ With all of that explained, let's start our dev-ready container! ```bash hl_lines="3 4 5 6 7" docker run -dp 3000:3000 \ - -w /app -v ${PWD}:/app \ + -w /app -v "$(pwd):/app" \ --network todo-app \ -e MYSQL_HOST=mysql \ -e MYSQL_USER=root \ @@ -194,7 +194,7 @@ With all of that explained, let's start our dev-ready container! ```powershell hl_lines="3 4 5 6 7" docker run -dp 3000:3000 ` - -w /app -v ${PWD}:/app ` + -w /app -v "$(pwd):/app" ` --network todo-app ` -e MYSQL_HOST=mysql ` -e MYSQL_USER=root ` diff --git a/docs/tutorial/using-bind-mounts/index.md b/docs/tutorial/using-bind-mounts/index.md index 9b714e7..072f32c 100644 --- a/docs/tutorial/using-bind-mounts/index.md +++ b/docs/tutorial/using-bind-mounts/index.md @@ -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`, diff --git a/docs/tutorial/using-docker-compose/index.md b/docs/tutorial/using-docker-compose/index.md index 568302a..9927500 100644 --- a/docs/tutorial/using-docker-compose/index.md +++ b/docs/tutorial/using-docker-compose/index.md @@ -53,7 +53,7 @@ To remember, this was the command we were using to define our app container. ```bash docker run -dp 3000:3000 \ - -w /app -v ${PWD}:/app \ + -w /app -v "$(pwd):/app" \ --network todo-app \ -e MYSQL_HOST=mysql \ -e MYSQL_USER=root \ @@ -67,7 +67,7 @@ If you are using PowerShell then use this command. ```powershell docker run -dp 3000:3000 ` - -w /app -v ${PWD}:/app ` + -w /app -v "$(pwd):/app" ` --network todo-app ` -e MYSQL_HOST=mysql ` -e MYSQL_USER=root ` @@ -116,7 +116,7 @@ docker run -dp 3000:3000 ` - 3000:3000 ``` -1. Next, we'll migrate both the working directory (`-w /app`) and the volume mapping (`-v ${PWD}:/app`) by using +1. Next, we'll migrate both the working directory (`-w /app`) and the volume mapping (`-v "$(pwd):/app"`) by using the `working_dir` and `volumes` definitions. Volumes also has a [short](https://docs.docker.com/compose/compose-file/#short-syntax-3) and [long](https://docs.docker.com/compose/compose-file/#long-syntax-3) syntax. One advantage of Docker Compose volume definitions is we can use relative paths from the current directory.