From 01dbbf0baef7707b1bf1c6c2755767b8edc52229 Mon Sep 17 00:00:00 2001 From: David Karlsson <35727626+dvdksn@users.noreply.github.com> Date: Tue, 28 Nov 2023 11:22:01 +0100 Subject: [PATCH] docs: rewrite section on working directory Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com> --- docs/reference/run.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/reference/run.md b/docs/reference/run.md index 70905ed7de67..99f03bb29b5d 100644 --- a/docs/reference/run.md +++ b/docs/reference/run.md @@ -1232,7 +1232,13 @@ The followings examples are all valid: ### Working directory The default working directory for running binaries within a container is the -root directory (`/`). It is possible to set a different working directory with the -Dockerfile `WORKDIR` command. The operator can override this with: +root directory (`/`). The default working directory of an image is set using +the Dockerfile `WORKDIR` command. You can override the default working +directory for an image using the `-w` (or `--workdir`) flag for the `docker +run` command: - -w="", --workdir="": Working directory inside the container +```text +$ docker run -w /home/$USER -it alpine +``` + +If the directory doesn't already exist in the container, it will be created.