Ejemplo n.º 1
0
        /// <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;
        }
        /// <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();

            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;
        }