[
https://issues.apache.org/jira/browse/MESOS-1816?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14168309#comment-14168309
]
Eugen Feller commented on MESOS-1816:
-------------------------------------
Hi Timothy,
Thanks a lot for providing the patches. I finally ended up doing the following
changes in the docker.cpp and test_framework.cpp files get it working:
In the docker.cpp file:
diff --git a/src/docker/docker.cpp b/src/docker/docker.cpp
index fa049f8..073a17b 100644
--- a/src/docker/docker.cpp
+++ b/src/docker/docker.cpp
@@ -367,10 +367,10 @@ Future<Nothing> Docker::run(
return Failure("Network mode has to be 'NONE' to support lxc configs");
}
- argv.push_back("--lxc-conf");
+ argv.push_back("--privileged=true");
foreach (const Parameter& param, dockerInfo.lxc_configs()) {
- argv.push_back(param.key() + " = " + param.value());
+ argv.push_back(param.key() + "=" + param.value());
}
}
The reasons for the changes are:
1) LXC + DHCP requires running in the priveleged mode. Might need to move the
push_back line to the appropriate place as it does not only apply for LXC
(other use cases might benefit from the priveleged mode).
2) Docker run expects multiple "--lxc-conf" flags to pass multiple settings
instead of one. For example: --lxc-conf="lxc.network.type = veth"
--lxc-conf="lxc.network.link = br0" --lxc-conf="lxc.network.name = eth0"
--lxc-conf="lxc.network.flags = up".
3) Had to remove the spaces in the foreach loop push_back as lxc-conf does not
accept them.
My test_framework.cpp file looks as follows:
diff --git a/src/examples/test_framework.cpp b/src/examples/test_framework.cpp
index 8be8c3f..78f237f 100644
--- a/src/examples/test_framework.cpp
+++ b/src/examples/test_framework.cpp
@@ -104,19 +104,36 @@ public:
task.mutable_slave_id()->MergeFrom(offer.slave_id());
CommandInfo command;
- command.set_value("ifconfig");
+ command.set_value("dhclient eth0; ifconfig eth0; service ssh start;
while [ 1 ]; do sleep 5; done");
ContainerInfo containerInfo;
containerInfo.set_type(ContainerInfo::DOCKER);
ContainerInfo::DockerInfo dockerInfo;
- dockerInfo.set_image("tnachen/test-executor");
-
- // Add lxc configs!!
-
- containerInfo.mutable_docker()->CopyFrom(dockerInfo);
- task.mutable_container->CopyFrom(containerInfo);
- task.mutable_command->CopyFrom(command);
+ dockerInfo.set_image("my_custom_image");
+
+ // LXC settings
+ dockerInfo.set_network(ContainerInfo::DockerInfo::NONE);
+
+ Parameter* parameter1 = dockerInfo.add_lxc_configs();
+ parameter1->set_key("--lxc-conf");
+ parameter1->set_value("\"lxc.network.type = veth\"");
+
+ Parameter* parameter2 = dockerInfo.add_lxc_configs();
+ parameter2->set_key("--lxc-conf");
+ parameter2->set_value("\"lxc.network.link = br0\"");
+
+ Parameter* parameter3 = dockerInfo.add_lxc_configs();
+ parameter3->set_key("--lxc-conf");
+ parameter3->set_value("\"lxc.network.name = eth0\"");
+
+ Parameter* parameter4 = dockerInfo.add_lxc_configs();
+ parameter4->set_key("--lxc-conf");
+ parameter4->set_value("\"lxc.network.flags = up\"");
+
+ containerInfo.mutable_docker()->CopyFrom(dockerInfo);
+ task.mutable_container()->CopyFrom(containerInfo);
+ task.mutable_command()->CopyFrom(command);
Best regards,
Eugen
> lxc execution driver support for docker containerizer
> -----------------------------------------------------
>
> Key: MESOS-1816
> URL: https://issues.apache.org/jira/browse/MESOS-1816
> Project: Mesos
> Issue Type: Improvement
> Components: containerization
> Affects Versions: 0.20.1
> Reporter: Eugen Feller
> Assignee: Timothy Chen
> Labels: docker
>
> Hi all,
> One way to get networking up and running in Docker is to use the bridge mode.
> The bridge mode results in Docker automatically assigning IPs to the
> containers from the IP range specified on the docker0 bridge.
> In our setup we need to manage IPs using our own DHCP server. Unfortunately
> this is not supported by Docker's libcontainer execution driver. Instead, the
> lxc execution driver
> (http://blog.docker.com/2014/03/docker-0-9-introducing-execution-drivers-and-libcontainer/)
> can be used. In order to use the lxc execution driver, Docker daemon needs
> to be started with the "-e lxc" flag. Once started, Docker own networking can
> be disabled and lxc options can be passed to the docker run command. For
> example:
> $ docker run -n=false --lxc-conf="lxc.network.type = veth"
> --lxc-conf="lxc.network.link = br0" --lxc-conf="lxc.network.name = eth0"
> -lxc-conf="lxc.network.flags = up" ...
> This will force Docker to use my own bridge br0. Moreover, IP can be assigned
> to the eth0 interface by executing the "dhclient eth0" command inside the
> started container.
> In the previous integration of Docker in Mesos (using Deimos), I have passed
> the aforementioned options using the "options" flag in Marathon. However,
> with the new changes this is no longer possible. It would be great to support
> the lxc execution driver in the current Docker integration.
> Thanks.
> Best regards,
> Eugen
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)