Example #1
0
        /// <summary>
        /// Creates a `IHostService` based on a _URI_.
        /// </summary>
        /// <param name="uri">The _URI_ to the docker daemon.</param>
        /// <param name="name">An optional name. If none is specified the _URI_ is the name.</param>
        /// <param name="isNative">If the docker daemon is native or not. Default to true.</param>
        /// <param name="stopWhenDisposed">If it should be stopped when disposed, default to false.</param>
        /// <param name="isWindowsHost">If it is a docker daemon that controls windows containers or not. Default false.</param>
        /// <param name="certificatePath">
        /// Optional path to where certificates are located in order to do TLS communication with docker daemon. If not provided,
        /// it will try to get it from the environment _DOCKER_CERT_PATH_.
        /// </param>
        /// <returns>A newly created host service.</returns>
        public IHostService FromUri(
            DockerUri uri,
            string name            = null,
            bool isNative          = true,
            bool stopWhenDisposed  = false,
            bool isWindowsHost     = false,
            string certificatePath = null)
        {
            if (string.IsNullOrEmpty(certificatePath))
            {
                certificatePath = Environment.GetEnvironmentVariable(DockerHostService.DockerCertPath);
            }

            if (string.IsNullOrEmpty(name))
            {
                name = uri.ToString();
            }

            return(new DockerHostService(
                       name, isNative, stopWhenDisposed, uri.ToString(), certificatePath, isWindowsHost
                       ));
        }