title | slug | weight |
---|---|---|
Dockerfile WORKDIR |
Dockerfile-WORKDIR |
11 |
The WORKDIR command is used to define the working directory of a Docker container at any given time. The command is specified in the Dockerfile.
Any RUN, CMD, ADD, COPY, or ENTRYPOINT command will be executed in the specified working directory.
FROM ubuntu
WORKDIR /var/www/html
RUN apt-get update && apt-get install -y nginx
COPY index.html .
ENTRYPOINT ["nginx", "-g", "daemon off;"]
docker build -t sangam14/workdir-dockerfile -f dockerfile.workdir .
docker run -p 80:80 sangam14/workdir-dockerfile
output