# Docker integration - unable to uninstall agent

**URL:** <https://discuss.elastic.co/t/docker-integration-unable-to-uninstall-agent/378567>\
**Category:** Elastic Agent\
**Tags:** fleet\
**Created:** [May 27, 2025, 7:14am UTC](https://discuss.elastic.co/t/docker-integration-unable-to-uninstall-agent/378567 "2025-05-27T07:14:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaimes410](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gaimes410/32/141637_2.png) [@gaimes410](https://discuss.elastic.co/u/gaimes410)\
**Post date:** [May 27, 2025, 7:14am UTC](https://discuss.elastic.co/t/docker-integration-unable-to-uninstall-agent/378567/1 "2025-05-27T07:14:48Z")

</div>

Hey there!

Im running elastic on-prem 8.18.1 with fleet-managed agents  
one of the policies running docker integration with a condition:

stringContains(${docker.container.name}, "containerName")

The integration with the condition is working.

The problem is that when I'm trying to uninstall an agent using elastic-agent uninstall or elastic-agent install --force (reinstallation) I'm getting the following error:

```auto
[===] Failed to uninstall agent [0s] Error uninstalling. Printing logs
2025-05-26T18:32:54.207Z	DEBUG	[uninstall.state_migration]	not attempting to migrate from action store: state store already exists
2025-05-26T18:32:54.542Z	DEBUG	[uninstall.state_migration]	not attempting to migrate from action store: state store already exists
Error: error uninstalling agent: error uninstalling components: error applying dynamic inputs: error unpacking subarray in config for skip key inputs: expected ',' when parsing 'stringContains(${docker.container.name}, "containerName")' accessing 'inputs.8' 
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.18/fleet-troubleshooting.html
[====] Uninstall failed [0s] Error: failed to uninstall elastic-agent: exit status 1
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.18/fleet-troubleshooting.html

```

The agents are running on Ubuntu 24 servers, with kibana, agents, Elastic, and fleet all running the same versions.  
I'm using Docker-Compose in order to run fleet, elastic, and kibana

The installation process is working fine

After removing the condition from the integration, I'm able to uninstall successfully

How can i safely uninstall or reinstall the agents without removing the condition? Is it a bug?

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [May 27, 2025, 7:10pm UTC](https://discuss.elastic.co/t/docker-integration-unable-to-uninstall-agent/378567/2 "2025-05-27T19:10:57Z")

</div>

Hi @gaimes410

Per the docs

> **[Uninstall Elastic Agents from edge hosts | Elastic Docs](https://www.elastic.co/docs/reference/fleet/uninstall-elastic-agent)**
>
> To uninstall Elastic Agent, run the uninstall command from the directory where Elastic Agent is running. Follow the prompts to confirm that you want to...

Are you running the command from outside in the install directory with the full path?

`sudo /opt/Elastic/Agent/elastic-agent uninstall`

Otherwise it will not uninstall properly...

---

<div class="post-metadata">

**Author:** ![gaimes410](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gaimes410/32/141637_2.png) [@gaimes410](https://discuss.elastic.co/u/gaimes410)\
**Post date:** [May 27, 2025, 7:30pm UTC](https://discuss.elastic.co/t/docker-integration-unable-to-uninstall-agent/378567/3 "2025-05-27T19:30:47Z")

</div>

Hey, thanks for the quick response!  
Yeah I've followed the guide correctly and as I've said, removing the agent was possible again after deleting the condition from the integration.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [May 27, 2025, 7:37pm UTC](https://discuss.elastic.co/t/docker-integration-unable-to-uninstall-agent/378567/4 "2025-05-27T19:37:00Z")

</div>

> [@gaimes410](#):
>
> Yeah I've followed the guide correctly and as I've said, removing the agent was possible again after deleting the condition from the integration.

Yeah that is weird... seems like a bug of some sort

---

<div class="post-metadata">

**Author:** ![gaimes410](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gaimes410/32/141637_2.png) [@gaimes410](https://discuss.elastic.co/u/gaimes410)\
**Post date:** [May 28, 2025, 5:48am UTC](https://discuss.elastic.co/t/docker-integration-unable-to-uninstall-agent/378567/5 "2025-05-28T05:48:28Z")

</div>

I have opened an issue on github on the matter

> <https://github.com/elastic/elastic-agent/issues/8259>
>
> Hi there!
> Im using elastic stack version 8.18.1 (elastic, kibana, elastic agent)…
> The agents are running on ubuntu 24 servers
> On my ubuntu servers I've configured agent policy that contains docker integration with the following condition:
> \`stringContains(${docker.container.name}, "containerName")\`
> the condition works fine, I'm receiving logs correctly
> When i try to uninstall the agent (using the exact commands and path from the official docs) I'm getting the following error:
> \`
> \[===\] Failed to uninstall agent \[0s\] Error uninstalling. Printing logs
> 2025-05-26T18:32:54.207Z	DEBUG	\[uninstall.state\_migration\]	not attempting to migrate from action store: state store already exists
> 2025-05-26T18:32:54.542Z	DEBUG	\[uninstall.state\_migration\]	not attempting to migrate from action store: state store already exists
> Error: error uninstalling agent: error uninstalling components: error applying dynamic inputs: error unpacking subarray in config for skip key inputs: expected ',' when parsing 'stringContains(${docker.container.name}, "containerName")' accessing 'inputs.8' 
> For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.18/fleet-troubleshooting.html
> \[====\] Uninstall failed \[0s\] Error: failed to uninstall elastic-agent: exit status 1
> For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.18/fleet-troubleshooting.html
> \`
> After modifying the docker integration in the fleet UI and removing the condition, the uninstall process words as expected
> 
> I've opened a discussion in the forums 
> https://discuss.elastic.co/t/docker-integration-unable-to-uninstall-agent/378567/2
> Which seems to approve that this behaviour is a bug
> 
> I've also noticed others in the forums with the same experiencing the same behaviour
> https://discuss.elastic.co/t/docker-integration-condition-not-working/377864
> I've tried to do elastic-agent inspect and got the same error message
> 
> \`
> Error: error printing config: error parsing config as hashmap: error unpacking subarray in config for skip key inputs: expected ',' when parsing 'stringContains(${docker.container.name}, "containerName")' accessing 'inputs.0' 
> For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.18/fleet-troubleshooting.html
> \`
> 
> I've also tried it with elastic stack version 9.0.1 on our test environment with the same outcome
> 
> How to reproduce:
> 1. Install elastic stack (I've done it using docker compose)
> 2. create a policy with docker integration with the condition above (or from the other forum)
> 3. Enroll the agent using the command from fleet ui
> 4. Wait for logs to start arriving (not mandatory, just to see if the condition works)
> 5. Try the command elastic-agent inspect (expected to fail)
> 6. Try the command elastic-agent uninstall (expected to fail)
