コード例 #1
0
        public void DiscoverShallReturnMachines()
        {
            if (!CommandExtensions.IsToolbox())
            {
                return;
            }

            try
            {
                var res = "test-machine".Create(1024, 20000, 1);
                Assert.AreEqual(true, res.Success);

                var start = "test-machine".Start();
                Assert.AreEqual(true, start.Success);

                var hosts = new Hosts().Discover();
                Assert.IsTrue(hosts.Count > 0);

                var tm = hosts.First(x => x.Name == "test-machine");
                Assert.IsNotNull(tm);
                Assert.AreEqual(false, tm.IsNative);
                Assert.AreEqual(ServiceRunningState.Running, tm.State);
            }
            finally
            {
                "test-machine".Delete(true /*force*/);
            }
        }
コード例 #2
0
        public ContainerBuilder Mount(string fqHostPath, string fqContainerPath, MountType access)
        {
            var hp = FdOs.IsWindows() && CommandExtensions.IsToolbox()
        ? ((TemplateString)fqHostPath).Rendered.ToMsysPath()
        : ((TemplateString)fqHostPath).Rendered;

            _config.CreateParams.Volumes =
                _config.CreateParams.Volumes.ArrayAdd($"{hp.EscapePath()}:{fqContainerPath.EscapePath()}:{access.ToDocker()}");
            return(this);
        }
コード例 #3
0
        public static string GetDockerHostEnvironmentPathOrDefault()
        {
            var env = Environment.GetEnvironmentVariable(DockerHost);

            if (null != env)
            {
                return(env);
            }

            if (FdOs.IsWindows())
            {
                return(CommandExtensions.IsToolbox() ? DockerHostUrlLegacy : DockerHostUrlWindowsNative);
            }

            return(CommandExtensions.IsToolbox() ? DockerHostUrlLegacy : DockerHostUrlMacOrLinux);
        }
コード例 #4
0
        /// <summary>
        /// Tries to autodetect the <see cref="CommandDefaults"/>.
        /// </summary>
        /// <remarks>
        /// http://docker-saigon.github.io/post/Docker-Beta/
        /// </remarks>
        public static void AutoDetect()
        {
            if (Common.OperatingSystem.IsWindows() || Common.OperatingSystem.IsOsx())
            {
                // Prefer non toolbox on windows and mac
                if (!CommandExtensions.IsToolbox())
                {
                    MachineDriver = Common.OperatingSystem.IsWindows() ? "hyperv" : "xhyve";

                    if (Common.OperatingSystem.IsWindows())
                    {
                        // TODO: Is it possible instead to use the proxy to proxy this machine
                        // TODO: for the default docker NAT switch instead?
                        MachineExtraDefaultCreateArgs = "--hyperv-virtual-switch external-switch {0}";
                    }
                }
            }
        }