/// <inheritdoc />
        protected override async Task ConfigureAsync()
        {
            await base.ConfigureAsync();

            WaitStrategy = new ExposedPortsWaitStrategy(new List <int>
            {
                RyukPort
            });
            ExposedPorts.Add(RyukPort);

            var dockerHostPath = (Environment.GetEnvironmentVariable("DOCKER_HOST"), Environment.GetEnvironmentVariable("TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE")) switch
            {
                ({ } s, _)when !string.IsNullOrEmpty(s) => new Uri(s).PathAndQuery,
                (null, { } s)when !string.IsNullOrEmpty(s) => s,
                _ => "/var/run/docker.sock"
            };

            BindMounts.Add(new Bind
            {
                // apparently this is the correct way to mount the docker socket on both windows and linux
                // mounting the npipe will not work
                HostPath = dockerHostPath,
                // ryuk is a linux container, so we have to mount onto the linux socket
                ContainerPath = "/var/run/docker.sock",
                AccessMode    = AccessMode.ReadOnly
            });

            AutoRemove = true;
        }
Beispiel #2
0
        /// <inheritdoc />
        protected override async Task ConfigureAsync()
        {
            await base.ConfigureAsync();

            ExposedPorts.Add(DefaultPort);
            Env.Add("POSTGRES_DB", DatabaseName);
            Env.Add("POSTGRES_USER", Username);
            Env.Add("POSTGRES_PASSWORD", Password);
        }
Beispiel #3
0
        /// <inheritdoc />
        protected override async Task ConfigureAsync()
        {
            // rigorous password validation ...
            // see: https://hub.docker.com/_/microsoft-mssql-server?tab=description
            ValidatePassword(Password);

            await base.ConfigureAsync();

            ExposedPorts.Add(DefaultPort);
            Env.Add("ACCEPT_EULA", "Y");
            Env.Add("SA_PASSWORD", Password);
        }
        /// <inheritdoc />
        protected override async Task ConfigureAsync()
        {
            if (string.IsNullOrEmpty(Password))
            {
                throw new InvalidOperationException("Root password cannot null or empty");
            }

            await base.ConfigureAsync();

            ExposedPorts.Add(DefaultPort);
            Env.Add("ARANGO_ROOT_PASSWORD", Password);

            WaitStrategy = new ProbingStrategy(Probe,
                                               typeof(HttpRequestException),       // when service isn't up yet
                                               typeof(InvalidOperationException)); // sometimes http server up but response still empty/null
        }
        /// <inheritdoc />
        protected override async Task ConfigureAsync()
        {
            await base.ConfigureAsync();

            WaitStrategy = new ExposedPortsWaitStrategy(new List <int> {
                RyukPort
            });
            ExposedPorts.Add(RyukPort);

            BindMounts.Add(new Bind
            {
                HostPath      = DockerClient.Configuration.EndpointBaseUri.AbsolutePath,
                ContainerPath = DockerClient.Configuration.EndpointBaseUri.AbsolutePath,
                AccessMode    = AccessMode.ReadOnly
            });

            AutoRemove = true;
        }
        /// <inheritdoc />
        protected override async Task ConfigureAsync()
        {
            await base.ConfigureAsync();

            ExposedPorts.Add(DefaultPort);
            Env.Add("MYSQL_DATABASE", DatabaseName);
            Env.Add("MYSQL_ALLOW_EMPTY_PASSWORD", "yes");

            if (Username == "root")
            {
                Env.Add("MYSQL_ROOT_PASSWORD", Password);
            }
            else
            {
                Env.Add("MYSQL_USER", Username);
                Env.Add("MYSQL_PASSWORD", Password);
            }
        }
        private CreateContainerParameters ApplyConfiguration()
        {
            var config = new Config
            {
                Image        = DockerImageName,
                Env          = Env.Select(kvp => $"{kvp.Key}={kvp.Value}").ToList(),
                ExposedPorts = ExposedPorts.ToDictionary(
                    e => string.Format(TcpExposedPortFormat, e),
                    e => default(EmptyStruct)),
                Labels       = Labels,
                WorkingDir   = WorkingDirectory,
                Cmd          = Command,
                Tty          = true,
                AttachStderr = true,
                AttachStdout = true,
            };

            return(new CreateContainerParameters(config)
            {
                HostConfig = new HostConfig
                {
                    AutoRemove = AutoRemove,
                    PortBindings = PortBindings.ToDictionary(
                        e => string.Format(TcpExposedPortFormat, e.Key),
                        e => (IList <PortBinding>) new List <PortBinding>
                    {
                        new PortBinding
                        {
                            HostPort = e.Value.ToString()
                        }
                    }),
                    Mounts = BindMounts.Select(m => new Mount
                    {
                        Source = m.HostPath,
                        Target = m.ContainerPath,
                        ReadOnly = m.AccessMode == AccessMode.ReadOnly,
                        Type = "bind"
                    })
                             .ToList(),
                    PublishAllPorts = true,
                    Privileged = IsPrivileged
                }
            });
        }
        /// <inheritdoc />
        protected override async Task ConfigureAsync()
        {
            await base.ConfigureAsync();

            WaitStrategy = new ExposedPortsWaitStrategy(new List <int> {
                RyukPort
            });
            ExposedPorts.Add(RyukPort);

            BindMounts.Add(new Bind
            {
                // apparently this is the correct way to mount the docker socket on both windows and linux
                // mounting the npipe will not work
                HostPath = "//var/run/docker.sock",
                // ryuk is a linux container, so we have to mount onto the linux socket
                ContainerPath = "/var/run/docker.sock",
                AccessMode    = AccessMode.ReadOnly
            });

            AutoRemove = true;
        }
        protected override async Task ConfigureAsync()
        {
            await base.ConfigureAsync();

            ExposedPorts.Add(KAFKA_PORT);
            ExposedPorts.Add(ZOOKEEPER_PORT);

            // Use two listeners with different names, it will force Kafka to communicate with itself via internal
            // listener when KAFKA_INTER_BROKER_LISTENER_NAME is set, otherwise Kafka will try to use the advertised listener
            Env["KAFKA_LISTENERS"] = "PLAINTEXT://0.0.0.0:" + KAFKA_PORT + ",BROKER://0.0.0.0:9092";
            Env["KAFKA_LISTENER_SECURITY_PROTOCOL_MAP"] = "BROKER:PLAINTEXT,PLAINTEXT:PLAINTEXT";
            Env["KAFKA_INTER_BROKER_LISTENER_NAME"]     = "BROKER";

            Env["KAFKA_BROKER_ID"] = "1";
            Env["KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR"] = "1";
            Env["KAFKA_OFFSETS_TOPIC_NUM_PARTITIONS"]     = "1";
            Env["KAFKA_LOG_FLUSH_INTERVAL_MESSAGES"]      = long.MaxValue + "";
            Env["KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS"] = "0";
            Command = new List <string>
            {
                "sh", "-c", "while [ ! -f " + STARTER_SCRIPT + " ]; do sleep 0.1; done; " + STARTER_SCRIPT
            };
        }
    protected override async Task ConfigureAsync()
    {
        await base.ConfigureAsync();

        ExposedPorts.Add(SQS_PORT);
    }