> For the complete documentation index, see [llms.txt](https://stakpak.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stakpak.gitbook.io/docs/archive/containerize-next.js-application.md).

# 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:
