# How to run packetbeat as non-root in Kubernetes?

**URL:** https://discuss.elastic.co/t/how-to-run-packetbeat-as-non-root-in-kubernetes/310862
**Category:** Beats
**Tags:** docker, packetbeat
**Created:** [July 28, 2022, 11:55am UTC](https://discuss.elastic.co/t/how-to-run-packetbeat-as-non-root-in-kubernetes/310862 "2022-07-28T11:55:23Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![yurikizio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yurikizio/32/108975_2.png) [@yurikizio](https://discuss.elastic.co/u/yurikizio)
#### Post date: [July 28, 2022, 11:55am UTC](https://discuss.elastic.co/t/how-to-run-packetbeat-as-non-root-in-kubernetes/310862/1 "2022-07-28T11:55:23Z")

</div>

Hi,

I want to run packetbeat as non-root user because of security issue and I didn't find any solution how to do it.  
I tried to use these securityContext settings and I received this error.

```auto
containers:
        - name: packetbeat-dynamic
          image: docker.elastic.co/beats/packetbeat-oss:8.3.1
          securityContext:
            capabilities:
              add:
                - NET_ADMIN
                - NET_RAW
                - NET_BIND_SERVICE
            privileged: false
            runAsUser: 1000
            runAsGroup: 1000
            runAsNonRoot: true
            allowPrivilegeEscalation: false
      securityContext:
        fsGroup: 1000

```

{"log.level":"error","@timestamp":"2022-07-28T11:47:13.831Z","log.origin":{"file.name":"instance/beat.go","file.line":1051},"message":"Exiting: sniffer loop failed: Error starting sniffer: any: You don't have permission to capture on that device (socket: Operation not permitted)","service.name":"packetbeat","ecs.version":"1.6.0"}

Exiting: sniffer loop failed: Error starting sniffer: any: You don't have permission to capture on that device (socket: Operation not permitted)

It works if I run it as root user like:

```auto
securityContext: 
  runAsUser: 0
  capabilities:
    add:
    - NET_ADMIN

```

It also works if I run it as a privileged user, but as I understood it's almost the same as running it as root user

```auto
         securityContext:
            capabilities:
              add:
                - NET_ADMIN
            privileged: true
            runAsUser: 1000
            runAsGroup: 1000
            runAsNonRoot: true
            allowPrivilegeEscalation: true

```

Is it possible to run it as non-root user?  
Does anyone know how to do it? Any examples will be helpful 🙂

Thanks in advance!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [August 25, 2022, 1:55pm UTC](https://discuss.elastic.co/t/how-to-run-packetbeat-as-non-root-in-kubernetes/310862/2 "2022-08-25T13:55:36Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
