/// <summary>
        ///   Renders the argument string from this instance.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            var sb = new StringBuilder();

            // Container identification
            sb.OptionIfExists("--name ", Name);
            sb.OptionIfExists("--pid=", Pid);
            sb.OptionIfExists("--uts=", Uts);
            sb.OptionIfExists("--ipc=", Ipc);
            if (!string.IsNullOrWhiteSpace(CidFile))
            {
                sb.Append($" --cidfile=\"{CidFile}\"");
            }

            if (null != HostIpMappings && 0 != HostIpMappings.Count)
            {
                sb.Append(" --add-host=");
                foreach (var mapping in HostIpMappings)
                {
                    sb.Append($"--add-host={mapping.Item1}:{mapping.Item2}");
                }
            }

            if (Ulimit.Count > 0)
            {
                foreach (var ulimit in Ulimit)
                {
                    sb.Append($" --ulimit {ulimit}");
                }
            }

            // Block IO bandwidth (Blkio) constraint
            if (null != BlockIoWeight)
            {
                sb.Append($" --blkio-weight {BlockIoWeight.Value}");
            }
            sb.OptionIfExists("--blkio-weight-device=", BlockIoWeightDevices);
            sb.OptionIfExists("--device-read-bps ", DeviceReadBps);
            sb.OptionIfExists("--device-read-iops=", DeviceReadIops);
            sb.OptionIfExists("--device-write-bps=", DeviceWriteBps);
            sb.OptionIfExists("--device-write-iops=", DeviceWriteIops);

            // Runtime privilege and Linux capabilities
            sb.OptionIfExists("--cap-add=", CapabilitiesToAdd);
            sb.OptionIfExists("--cap-drop=", CapabilitiesToRemove);
            if (Privileged)
            {
                sb.Append(" --privileged");
            }
            sb.OptionIfExists("--device=", Device);

            // Network settings
            sb.OptionIfExists("--dns=", Dns);
            sb.OptionIfExists("--dns-opt=", DnsOpt);
            sb.OptionIfExists("--dns-search=", DnsSearch);
            sb.OptionIfExists("--hostname ", Hostname);
            if (!PublishAllPorts)
            {
                sb.OptionIfExists("-p ", PortMappings);
            }
            else
            {
                sb.Append(" -P");
            }

            // Native health check
            sb.OptionIfExists("--health-cmd=", HealthCheckCmd);
            sb.OptionIfExists("--health-interval=", HealthCheckInterval);
            sb.OptionIfExists("--health-timeout=", HealthCheckTimeout);
            sb.OptionIfExists("--health-start-period=", HealthCheckStartPeriod);
            sb.OptionIfExists("--no-healthcheck", HealthCheckDisabled);

            if (HealthCheckRetries > 0)
            {
                sb.Append($" --health-retries={HealthCheckRetries}");
            }


            sb.OptionIfExists("--cgroup-parent ", ParentCGroup);
            sb.OptionIfExists("-e ", Environment);
            sb.OptionIfExists("--env-file=", EnvironmentFiles);

            if (Interactive)
            {
                sb.Append(" -i");
            }

            if (Tty)
            {
                sb.Append(" -t");
            }

            sb.OptionIfExists("-u ", AsUser);

            if (AutoRemoveContainer)
            {
                sb.Append(" --rm");
            }

            sb.OptionIfExists("-v ", Volumes);
            sb.OptionIfExists("--volume-driver ", VolumeDriver);
            sb.OptionIfExists("--volumes-from=", VolumesFrom);
            sb.OptionIfExists("-w ", WorkingDirectory);

            sb.OptionIfExists("--link=", Links);
            sb.OptionIfExists("-l ", Labels);
            sb.OptionIfExists("--group-add=", Groups);
            sb.OptionIfExists("--network ", Network);
            sb.OptionIfExists("--ip ", Ipv4);
            sb.OptionIfExists("--ip6 ", Ipv6);

            if (RestartPolicy.No != RestartPolicy)
            {
                switch (RestartPolicy)
                {
                case RestartPolicy.Always:
                    sb.Append(" --restart always");
                    break;

                case RestartPolicy.OnFailure:
                    sb.Append(" --restart on-failure");
                    break;

                case RestartPolicy.UnlessStopped:
                    sb.Append(" --restart unless-stopped");
                    break;

                default:
                    sb.Append(" --restart no");
                    break;
                }
            }

            // Memory management
            sb.SizeOptionIfValid("--memory=", Memory, 4 * 1024 * 1024 /*4m*/);
            sb.SizeOptionIfValid("--memory-swap=", MemorySwap);
            sb.OptionIfExists("--memory-swappiness=", MemorySwappiness);
            sb.SizeOptionIfValid("--memory-reservation=", MemoryReservation);
            sb.SizeOptionIfValid("--kernel-memory=", KernelMemory);
            if (OomKillDisable)
            {
                sb.Append(" --oom-kill-disable");
            }

            // Cpu management
            if (!Cpus.IsApproximatelyEqualTo(float.MinValue))
            {
                sb.Append($" --cpus=\"{Cpus}\"");
            }
            sb.OptionIfExists("--cpuset-cpus=", CpusetCpus);
            if (CpuShares != int.MinValue)
            {
                sb.Append($" --cpu-shares=\"{CpuShares}\"");
            }

            // Runtime
            if (Runtime != ContainerRuntime.Default)
            {
                sb.Append($" --runtime={Runtime.ToString().ToLower()}");
            }

            var isolation = Isolation.ToDocker();

            if (null != isolation)
            {
                sb.Append($" --isolation {Isolation.ToDocker()}");
            }
            return(sb.ToString());
        }
        public override string ToString()
        {
            var sb = new StringBuilder();

            sb.OptionIfExists("--build-arg ", BuildArguments);
            sb.OptionIfExists("--cpu-shares ", CpuShares?.ToString());
            sb.OptionIfExists("--cgroup-parent ", ParentCGroup?.ToString());
            sb.OptionIfExists("--cpu-period ", CpuPeriod?.ToString());
            sb.OptionIfExists("--cpu-quota ", CpuQuota?.ToString());
            sb.OptionIfExists("--cpuset-cpus", AllowCpuExecution);
            sb.OptionIfExists("--cpuset-mems ", AllowMemExecution);

            if (SkipImageVerification)
            {
                sb.Append(" --disable-content-trust=true");
            }

            sb.OptionIfExists("-f ", File);

            if (ForceRemoveIntermediateContainers)
            {
                sb.Append(" --force-rm");
            }

            if (null != Isolation.ToDocker())
            {
                sb.Append($"--isolation {Isolation.ToDocker()}");
            }

            sb.OptionIfExists("--label=", Labels);
            sb.OptionIfExists("-m ", Memory?.ToString());
            sb.OptionIfExists("--memory-swap ", Swap?.ToString());

            if (NoCache)
            {
                sb.Append(" --no-cache");
            }

            if (AlwaysPull)
            {
                sb.Append(" --pull");
            }

            if (Quiet)
            {
                sb.Append(" -q");
            }

            if (RemoveIntermediateContainersOnSuccessfulBuild)
            {
                sb.Append(" --rm=true");
            }

            sb.OptionIfExists("--shm-size ", ShmSize?.ToString());
            sb.OptionIfExists("-t ", Tags);
            sb.OptionIfExists("--ulimit=", UlimitOptions);
            if (NoCache)
            {
                sb.Append(" --no-cache");
            }

            return(sb.ToString());
        }