How to use nmcli command in a docker container?

You need to execute the network manager commands through DBUS, which means you can’t just do nmcli inside the container and expect it to work. You can see here: https://github.com/NetworkManager/NetworkManager/blob/master/examples/shell/disconnect-device.sh for example how the dbus-send command is used to send a command through DBUS to the NetworkManager. I think the code there is a great example on how to achieve what you want to do.