# Upgrading the Portainer Agent

The Portainer Agent is simple to upgrade, this process can be done either [through the Portainer UI](/portainer/the-portainer-agent/upgrading-the-portainer-agent.md#upgrade-the-agent-through-the-portainer-ui) or [through the CLI](/portainer/the-portainer-agent/upgrading-the-portainer-agent.md#upgrade-the-agent-through-the-cli).

## Through the Portainer UI

The simplest way to upgrade the Portainer Agent is through the Portainer UI.\
\
**Step 1:** Navigate to the Services view through the menubar of Portainer and select the checkbox of thhe Agent service you wish to upgrade, and click the update button.

![](/files/-LaDMUYUaGUt60r-o3Ip)

**Step 2:** A message will appear asking if you want to force an update. Make sure that 'Pull latest image version' is selected as shown below before clicking the update button.

![](/files/-LaDMXJNF5ZXMg6DggqQ)

**A confirmation message like the one below should appear in the top right corner of the Portainer UI if the Agent has been successfully updated.**

![](/files/-LaDMZoI0_5-5z86vnFI)

## Through the CLI

{% hint style="warning" %}
**Note:** You need to make sure you are accessing the swarm manager node via the CLI to issue the below command
{% endhint %}

Enter the below command into the CLI (assuming your Docker service is called *portainer*). You can replace *portainer* with the name of your service if yours is named something different.

```
docker service update --image portainer/portainer:latest portainer
```

**You are done!**


---

# 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://portainer.gitbook.io/portainer/the-portainer-agent/upgrading-the-portainer-agent.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.
