# Dockerfile Order of Execution

This lesson focuses on the order that instructions are executed in when building an image. Some instructions may have unintended consequences that can cause your build to fail.

Step 1: Setup your environment:

```bash
mkdir centos-conf
```

```bash
cd centos-conf
```

Step 2: Create the Dockerfile:

```bash
vi Dockerfile
```

Step 3: Creates a CentOS image that uses cloud\_user as a non-privileged user

Dockerfile contents:

```bash
FROM centos:latest
RUN mkdir -p ~/new-dir1
RUN useradd -ms /bin/bash cloud_user
USER cloud_user
RUN mkdir -p ~/new-dir2
RUN mkdir -p /etc/myconf
RUN echo "Some config data" >> /etc/myconf/my.conf
```

Step 4: Build the new image:

```bash
docker image build -t centos7/myconf:v1 .
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://nishanthkp.gitbook.io/devsecops-for-bbk/dockerfile/dockerfile-order-of-execution.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
