Skip to content

using lxc_conf in start #79

@ureyes84

Description

@ureyes84

How do I use lxc_conf in start?

I'd like to set cpu and cpu shares, something like this:

docker run -i -t -lxc-conf="lxc.cgroup.cpu.shares=1" -lxc-conf="lxc.cgroup.cpuset.cpus=0" my_image /bin/bash stress_cpu.sh

According to the documentation I should be able to pass a dictionary:

lxc_conf allows to pass LXC configuration options in dict form.

So my code looks like this:

self.client.start(container, lxc_conf = self.get_lxc_conf())
def get_lxc_conf(self):        
  return {
  #Restrict container to a core
  'lxc.cgroup.cpuset.cpus' : str(self.cpu_number), 
  #All containers get the same share
  'lxc.cgroup.cpu.cpu.shares' : str(1) 
}

However, I can't get it work, I keep getting the following error message:

500 Server Error: Internal Server Error ("json: cannot unmarshal object into Go value of type []docker.KeyValuePair")

I get the same error even with the dictionary example in the API docs:

def get_lxc_conf(self):
    return {"lxc.utsname":"docker"}

I've tried passing lists and strings

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions