# How to run nmcli in balena node-red container

**URL:** <https://forums.balena.io/t/how-to-run-nmcli-in-balena-node-red-container/361727>\
**Category:** Product support\
**Tags:** docker, network, raspberrypizero\
**Created:** [September 9, 2022, 10:29pm UTC](https://forums.balena.io/t/how-to-run-nmcli-in-balena-node-red-container/361727 "2022-09-09T22:29:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elsevero](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/elsevero/32/5697_2.png) [@elsevero](https://forums.balena.io/u/elsevero)\
**Post date:** [September 9, 2022, 10:29pm UTC](https://forums.balena.io/t/how-to-run-nmcli-in-balena-node-red-container/361727/1 "2022-09-09T22:29:56Z")

</div>

Hi there,

I am trying to execute the following command in node-red: `nmcli device disconnect wlan0 ` using exec:

![image](https://global.discourse-cdn.com/balena/original/2X/c/cd1286a63e5e391f63ab31780d3c2869173899b1.png)

My `docker-compose.yml` file looks like:

```auto
node-red:
    build: ./node-red/node-red
    volumes:
      - 'app-data:/data'
    restart: always
    privileged: true
    network_mode: host
    labels:
      io.balena.features.dbus: '1'
      io.balena.features.firmware: '1'
      io.balena.features.supervisor-api: '1'
    cap_add:
      - SYS_RAWIO
    devices:
      - "/dev/mem:/dev/mem"
      - "/dev/gpiomem:/dev/gpiomem"
      - "/dev/i2c-1:/dev/i2c-1"
      - "/dev/ttyUSB0:/dev/ttyUSB0"
    expose:
      - "80"
    depends_on:
      - google-iot
    environment:
      GOOGLE_CLOUD_PROJECT: 'google-iot-project'
      GOOGLE_IOT_REGION: 'google-iot-region'
      GOOGLE_IOT_REGISTRY: 'google-iot-registry'
      GOOGLE_IOT_SERVICE_ACCOUNT_TOKEN: 'google-iot-service-account-token'
      USERNAME: 'node-red-user'
      PASSWORD: 'node-red-hashed-password'
      PORT: 1234

```

and Dockerfile of node-red like this:

```auto
###
# Build step
###
FROM balenalib/%%BALENA_MACHINE_NAME%%-debian-node:12-stretch-build as build

WORKDIR /

COPY ./node-red-contrib-iot-in-gcp /node-red-contrib-iot-in-gcp

RUN JOBS=MAX npm install -g --production --unsafe-perm \
       node-red \
       node-red-contrib-modbus \
       node-red-contrib-google-iot-core

RUN JOBS=MAX npm install -g /node-red-contrib-iot-in-gcp

###
# Runtime image
###
FROM balenalib/%%BALENA_MACHINE_NAME%%-debian-node:12-stretch-run

RUN apt-get update && apt-get install -yq --no-install-recommends \
  rpi.gpio \
  python-dev \
  python-rpi.gpio \
  libatomic1 \
  && apt-get clean && rm -rf /var/lib/apt/lists/*

# Defines our working directory in container
WORKDIR /usr/src/app

# Copy over the files created in the previous step, including lib/, bin/
COPY --from=build /usr/local/bin /usr/local/bin
COPY --from=build /usr/local/lib/node_modules /usr/local/lib/node_modules
COPY --from=build /node-red-contrib-iot-in-gcp /usr/local/lib/node_modules/node-red-contrib-iot-in-gcp

# This will copy all files in our root to the working directory in the container
COPY ./app ./
COPY ./wait-for-it ./wait-for-it

RUN chmod +x ./wait-for-it/wait-for-it.sh

# server.js will run when container starts up on the device
CMD ["bash", "/usr/src/app/start.sh", "bash", "/usr/src/app/wait-for-it/wait-for-it.sh google-iot:8883 -- echo Google IoT Service is up and running"]

```

**[I have red the documentation on this link](https://www.balena.io/docs/learn/develop/runtime/#dbus-communication-with-host-os) but could not figure out how to specify the command in node-red exec.**

**Do I need to specify something beside in the docker-compose file?**  
**Do I need to install something or modify the Dockerfile as well ?**  
**Am I missing something? Looking forward for a solution.**

---

<div class="post-metadata">

**Author:** ![mpous](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mpous/32/4742_2.png) [@mpous](https://forums.balena.io/u/mpous)\
**Post date:** [September 12, 2022, 11:03am UTC](https://forums.balena.io/t/how-to-run-nmcli-in-balena-node-red-container/361727/2 "2022-09-12T11:03:34Z")

</div>

> [@elsevero](#):
>
> `nmcli device disconnect wlan0 `

If i’m not wrong, I think that you only can run this command from HostOS and now you are trying to run this command from the nodeRED service.

Check this documentation to see if then this works → [BalenaOS Masterclass - Balena Documentation](https://www.balena.io/docs/learn/more/masterclasses/host-os-masterclass/#522-via-dbus-from-inside-a-container)

On the other hand, did try to run this the nmcli API? looks old but worth it to give a try → [GitHub - balena-io-modules/nm-api: NetworkManager DBUS API](https://github.com/balena-io-modules/nm-api)
