How can we add capabilities to a running docker container?

前端 未结 3 985
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-31 13:27

Is it possible to add a capability (for ex: NET_ADMIN) after the container has actually started?

I started a container few days ago and a service provided by it is b

3条回答
  •  执念已碎
    2020-12-31 13:45

    VanagaS

    1.Stop Container:

    docker stop yourcontainer;
    

    2.Get container id:

    docker inspect yourcontainer;
    

    3.Modify hostconfig.json(default docker path:/var/lib/docker, you can change yours)

    vim /var/lib/docker/containers/containerid/hostconfig.json
    

    4.Search "CapAdd", and modify null to ["NET_ADMIN"];

    ....,"VolumesFrom":null,"CapAdd":["NET_ADMIN"],"CapDrop":null,....
    

    5.Restart docker in host machine;

    service docker restart;
    

    6.Start yourconatiner;

    docker start yourcontainer;
    

    it work for me, enjoy it.

提交回复
热议问题