1

I am preparing a test automation which require me to install network manager so that the code api(which uses python3-networkmanager) could be tested.

In the docker file, I tried installing:

apt-get install dbus \
                network-manager

start receiving error:

networkmanager.systems do not have hostname property. 

I looked for solutions, but appears that will require:

  1. Privilege user (cannot use privilege user, project requirement)
  2. Reboot after installing same. (in docker, hence, can't reboot)

This leaves me with an only option for mocking debian networkmanager that can communicate with python3-networkmanager.

Trying to figure out, how I can mock same?

Chirag Dhyani
  • 863
  • 11
  • 24
  • The networking environment in Docker is _very_ different from "normal" Linux. If you're trying to write a tool that interacts with Network Manager, it probably needs to run in a full virtual machine with a normal network interface that expects to be configured. – David Maze Dec 04 '19 at 11:51
  • See: https://stackoverflow.com/questions/52654962/nmcli-in-a-docker-container/54914701 – ofirule Apr 23 '20 at 20:10

2 Answers2

0
RUN apt-get update && apt-get install -y \
    network-manager

worked for me.

Livne Rosenblum
  • 196
  • 1
  • 12
0

I would like to contribute as I had to spend some time getting it to work.

Inside the dockerfile you have to add:

RUN apt-get update && apt-get install -y network-manager dbus

Also, I added a script to start the network manager:

#!/bin/bash

service dbus start
service NetworkManager start

Then in the Dockerfile you have to call this start script at the end:

COPY start_script.sh /etc/init/
ENTRYPOINT ["/etc/init/start_script.sh"]

Now you can build your container and run it like this:

docker run --net="host" -v /run/dbus/system_bus_socket:/run/dbus/system_bus_socket container

For me, it is enough to work with OrangePi and Docker without a privileged container.

fatihyildizhan
  • 8,614
  • 7
  • 64
  • 88