How to pass docker options --mac-address, -v etc i

2020-07-18 06:46发布

I have installed a 50 node Kubernetes cluster in our lab and am beginning to test it. The problem I am facing is that I cannot find a way to pass the docker options needed to run the docker container in Kubernetes. I have looked at kubectl as well as the GUI. An example docker run command line is below:

sudo docker run -it --mac-address=$MAC_ADDRESS \
    -e DISPLAY=$DISPLAY -e UID=$UID -e XAUTHORITY=$XAUTHORITY \
    -e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
    -v /tmp/.X11-unix:/tmp/.X11-unix:ro \
    -v /mnt/lab:/mnt/lab -v /mnt/stor01:/mnt/stor01 \
    -v /mnt/stor02:/mnt/stor02 -v /mnt/stor03:/mnt/stor03 \
    -v /mnt/scratch01:/mnt/scratch01 \
    -v /mnt/scratch02:/mnt/scratch02 \
    -v /mnt/scratch03:/mnt/scratch03 \ 
    matlabpipeline $ARGS`

My first question is whether we can pass these docker options or not ? If there is a way to pass these options, how do I do this ?

Thanks...

1条回答
Melony?
2楼-- · 2020-07-18 07:17

I looked into this as well and from the sounds of it this is an unsupported use case for Kubernetes. Applying a specific MAC address to a docker container seems to conflict with the overall design goal of easily bringing up replica instances. There are a few workarounds suggested on this Reddit thread. In particular the OP finally decides the following...

I ended up adding the NET_ADMIN capability and changing the MAC to an environment variable with "ip link" in my entrypoint.sh.

查看更多
登录 后发表回答