Constructs the flags for the `mesos-docker-executor`. Custom docker executors will also be invoked with these flags. NOTE: `taskEnvironment` is currently used to propagate environment variables from a hook: `slavePreLaunchDockerEnvironmentDecorator`.
| 243 | // NOTE: `taskEnvironment` is currently used to propagate environment variables |
| 244 | // from a hook: `slavePreLaunchDockerEnvironmentDecorator`. |
| 245 | ::mesos::internal::docker::Flags dockerFlags( |
| 246 | const Flags& flags, |
| 247 | const string& name, |
| 248 | const string& directory, |
| 249 | const Option<map<string, string>>& taskEnvironment) |
| 250 | { |
| 251 | ::mesos::internal::docker::Flags dockerFlags; |
| 252 | dockerFlags.container = name; |
| 253 | dockerFlags.docker = flags.docker; |
| 254 | dockerFlags.sandbox_directory = directory; |
| 255 | dockerFlags.mapped_directory = flags.sandbox_directory; |
| 256 | dockerFlags.docker_socket = flags.docker_socket; |
| 257 | dockerFlags.launcher_dir = flags.launcher_dir; |
| 258 | |
| 259 | if (taskEnvironment.isSome()) { |
| 260 | dockerFlags.task_environment = string(jsonify(taskEnvironment.get())); |
| 261 | } |
| 262 | |
| 263 | if (flags.default_container_dns.isSome()) { |
| 264 | dockerFlags.default_container_dns = |
| 265 | string(jsonify(JSON::Protobuf(flags.default_container_dns.get()))); |
| 266 | } |
| 267 | |
| 268 | #ifdef __linux__ |
| 269 | dockerFlags.cgroups_enable_cfs = flags.cgroups_enable_cfs, |
| 270 | #endif |
| 271 | |
| 272 | // TODO(alexr): Remove this after the deprecation cycle (started in 1.0). |
| 273 | dockerFlags.stop_timeout = flags.docker_stop_timeout; |
| 274 | |
| 275 | return dockerFlags; |
| 276 | } |
| 277 | |
| 278 | |
| 279 | Try<DockerContainerizerProcess::Container*> |
| 280 | DockerContainerizerProcess::Container::create( |
| 281 | const ContainerID& id, |
| 282 | const ContainerConfig& containerConfig, |
| 283 | const map<string, string>& environment, |
| 284 | const Option<string>& pidCheckpointPath, |
| 285 | const Flags& flags) |
| 286 | { |
| 287 | // We need to extract a SlaveID based on the sandbox directory, |
| 288 | // for the purpose of working around a limitation of the Docker CLI. |
| 289 | // If the sandbox directory contains a colon, the sandbox directory |
| 290 | // cannot be mounted directly into the container directory. Instead, |
| 291 | // we symlink the sandbox directory and mount the symlink. |
| 292 | // See MESOS-1833 for more details. |
| 293 | Try<paths::ExecutorRunPath> runPath = |
| 294 | paths::parseExecutorRunPath(flags.work_dir, containerConfig.directory()); |
| 295 | |
| 296 | CHECK_SOME(runPath) << "Unable to determine SlaveID from sandbox directory"; |
| 297 | |
| 298 | string dockerSymlinkPath = path::join( |
| 299 | paths::getSlavePath(flags.work_dir, runPath->slaveId), |
| 300 | DOCKER_SYMLINK_DIRECTORY); |
| 301 | |
| 302 | Try<Nothing> mkdir = os::mkdir(dockerSymlinkPath); |