11.Dockerfile Lab - WORKDIR instruction

Dockerfile Lab 5

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.

WORKDIR instruction Dockerfile for Docker Quick Start

FROM ubuntu
WORKDIR /var/www/html
RUN apt-get update && apt-get install -y nginx
COPY index.html .
ENTRYPOINT ["nginx", "-g", "daemon off;"]

build dockerfile

docker build -t sangam14/workdir-dockerfile  -f dockerfile.workdir .

run docker container

docker run -p 80:80 sangam14/workdir-dockerfile 


© 2019-2023 @CloudNativeFolks | Documentation Distributed under Apache 2.0 License.

© 2023 Happy to help you with your Cloud Native Journey.