docker_practice/image/dockerfile/workdir.md

37 lines
1.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# WORKDIR
`WORKDIR <工作目录路径>`
使 `WORKDIR` `WORKDIR`
`Dockerfile` Shell
```docker
RUN cd /app
RUN echo "hello" > world.txt
```
`Dockerfile` `/app/world.txt` `hello` Shell `Dockerfile` `RUN` `Dockerfile`
`RUN` `RUN cd /app`
使 `WORKDIR`
```docker
WORKDIR /app
RUN echo "hello" > world.txt
```
`WORKDIR` 使 `WORKDIR`
```docker
WORKDIR /a
WORKDIR b
WORKDIR c
RUN pwd
```
`pwd` `/a/b/c`