# Deploy an Agent System in a Container

Based on the notes provided in the image, we'll help you create a tutorial on **accessing the agent system runtime after deploying it to Docker**. This tutorial will explain the steps for building the Docker container, deploying the agent system, and accessing the runtime for inference or interaction.

***

### Tutorial: Accessing the Agent System Runtime After Deploying to Docker

Once you have packaged and deployed your agent system inside a Docker container (<https://docs.amesa.com/deploy-agents/deploy-an-agent-in-a-container>), the next step is accessing its runtime for operations like model inference. This tutorial will guide you through the process of building and running the Docker container and then connecting to the agent system's runtime for further interactions.

***

### Step 1: Preparing the Dockerfile and Environment

To deploy the agent system to Docker, we need to first create an image from the **Dockerfile** (<https://docs.amesa.com/deploy-agents/deploy-an-agent-in-a-container>). The Dockerfile will package the necessary runtime, model, and environment for the agent system.

<div align="left"><figure><img src="/files/etrUAOahVo4TrWZzgF7o" alt=""><figcaption></figcaption></figure></div>

### Step 2: Building the Docker Image

1. **Building the Image**: You can build the Docker image by running the following command in the terminal. This will take the Dockerfile and the associated files (like the pre-trained model) and create an image.

```bash
docker build -t composabl_agent_api .
```

* The `-t` flag allows you to tag the image (`composabl_agent_api`), which makes it easier to reference later.
* Make sure that the model file (`agent.json`) and all relevant scripts are reachable within the Docker context (i.e., the directory from which you are building).

2. **Checking the Image**: Once the build is complete, you can verify that the image was created successfully by running:

```bash
docker images
```

***

### Step 3: Running the Docker Container

Now that the image is built, the next step is to run it in a container. You will run the Docker container in an interactive mode to access the runtime.

```bash
docker run -e AMESA_LICENSE="<your_license>" -it -p 8000:8000 composabl_agent_api
```

* `-it`: Runs the container interactively.
* `-p 8000:8000`: Maps port 8000 from the container to port 8000 on your local machine so that you can access the HTTP server for the agent system runtime.
* `-e` AMESA\_LICENSE="\<your\_license>" : is exporting the environment variable and linking to your composabl license

The HTTP server should now be up and running within the container, ready to handle model inference or other tasks.

***

### Step 4: Accessing the Agent System Runtime

With the Docker container running, you can now connect to the agent system's runtime. The runtime will be an HTTP server, as mentioned in your notes. You can access it through a POST request for model inference or other operations.

1. **Sending Requests to the Agent System**: You can send a POST request to the running server using a tool like `curl`, Postman, or any Python HTTP library (such as `requests`).

Here’s an example using `curl`:

```bash
curl -X POST http://localhost:8000/predict -H "Content-Type: application/json" -d '{"observation": {"T": 311.0, "Tc": 292.0, "Ca": 8.56, "Cref": 8.56, "Tref": 311.0, "Conc_Error": 0.0, "Eps_Yield": 0.0, "Cb_Prod": 0.0}}'
```

This request will:

* POST data to the `/predict` endpoint on `localhost:8000`, which is being forwarded from the Docker container.
* The agent system will handle the request, infer the model, and return the action as a result.

***

### Conclusion

In this tutorial, we walked through the process of:

* Building a Docker image with your agent system and its runtime.
* Running the Docker container interactively to expose the agent system’s HTTP server.
* Accessing the agent system runtime by sending HTTP requests for inference or other tasks.

By following these steps, you can deploy and interact with your AMESA agent system in a Dockerized environment.


---

# 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://docs.amesa.com/deploy-agents/deploy-an-agent-in-a-container.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.
