# Containerize Next.js Application

&#x20;By the end of the guide, Stakpak's AI agent will:

* Create the Dockerfile
* Build and run the Next.js app in a Docker container

1. Go to <https://stakpak.dev/> , sign in and create a new flow.
2. Click on agent (top-right corner).

<figure><img src="/files/7NrwzeHP5meWUGeDb9FP" alt=""><figcaption><p>Agent in UI</p></figcaption></figure>

3. Start by ensuring the Stakpak CLI is installed. If it's not, install it first before proceeding with the agent's steps. [Broken mention](broken://pages/dluTQDlPJwlDVDiClOeU)

<figure><img src="/files/wMxD83tf0sMZ3BJ0J5vT" alt=""><figcaption><p>Install Stakpak CLI</p></figcaption></figure>

4. Choose **dave** agent. This is the agent that creates Dockerfiles to containerize your app.

<figure><img src="/files/W7YJU2WOerOlhBzPsxJ8" alt=""><figcaption><p>Choose your AI Agent</p></figcaption></figure>

5. Copy & run the command on your terminal to start the agent session.

<figure><img src="/files/1n01iTKYhbENqYJDNJFA" alt=""><figcaption><p>Command to run on terminal</p></figcaption></figure>

6. Answer the questions the AI agent asks based on your app. Provide as much information and dependencies as possible.

<figure><img src="/files/mgNwD12pU1fyqT1wXgbd" alt=""><figcaption><p>Questions from the AI agent</p></figcaption></figure>

7. The agent creates the Dockerfile.

<figure><img src="/files/rq8dzYHTck1HfYgWErvY" alt=""><figcaption><p>Creating the Dockerfile</p></figcaption></figure>

7. Accept the command to run the Docker container. Each step has it's reasoning.

<figure><img src="/files/HqgTQyLup1X6ymvjo9jl" alt=""><figcaption><p>Commands run by the AI agent</p></figcaption></figure>

8. Once the agent finishes all steps, the status will be changed to **Complete**.&#x20;

<figure><img src="/files/ifMZeknMgEGiHlRsQ0O6" alt=""><figcaption><p>Agent completed containerization</p></figcaption></figure>

9. Congrats! Your app is ready to use! :tada:

<figure><img src="/files/tAhpXYg3hK7xYMbgboBk" alt=""><figcaption><p>Successful containerization</p></figcaption></figure>

You now have the Dockerfile in your directory and your docker container up and running! :dancer:All autonomous :robot:

**P.S.** (Pretty Sweet bonus info): try containerizing any app —Flask, FastAPI, Next.js, Node.js, you name it)— with your AI DevOps agent! :wink::rocket:


---

# 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://stakpak.gitbook.io/docs/archive/containerize-next.js-application.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.
