docker_practice/image/dockerfile/workdir.md

37 lines
1.7 KiB
Go
Raw Normal View History

# WORKDIR
`WORKDIR <工作目录路径>`
使 `WORKDIR` `WORKDIR`
`Dockerfile` Shell
2017-11-23 23:48:52 +08:00
```docker
RUN cd /app
RUN echo "hello" > world.txt
```
2017-11-23 23:48:52 +08:00
`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
```
2021-03-11 23:09:37 +08:00
`RUN pwd` `/a/b/c`