Oh Docker and your stupid obscure errors how I hate thee - I’m sure its something _I’ve_ done - but you’re not making this easy.
@talios Paste the error so we can mock you :)
@SaturniusMons It’s more #TestContainer’s at the moment - I did manage to trace one issue down to me dropping an EXPOSE line in the DockerFile ( which didn’t break the app as its in compose’s yaml etc ) - but not getting https://gist.github.com/talios/b50892f78de546b3d783a6eae8870a82 - with TestContainers failing saying `nc: not found` (which doesn’t exist in my container, but never did), definitely something odd with networking.
gist:b50892f78de546b3d783a6eae8870a82

GitHub Gist: instantly share code, notes, and snippets.

Gist

@talios Oh, I saw you say this on the bird the other day?

Just install netcat and see if that gets you a new error :)

@SaturniusMons Well I tried - for some stupid non-erroring reason, installing netcat….. doesn’t install netcat - but it seems like somehow I’m running multiple docker daemons reporting different sets of images - WAT
@SaturniusMons Resolved that and now have netcat in my image - problem still exists. Boo

@talios Oh, ok

https://stackoverflow.com/questions/71613887/testcontainers-with-sftp-image-throws-error-on-nc-not-found-or-address-not-av

Testcontainers runs a couple of commands from within the container to determine when the intenral port of the container is available: https://github.com/testcontainers/testcontainers-java/blob/5e6dbc791b6184f0de6d1f9d184a78324c1ec945/core/src/main/java/org/testcontainers/containers/wait/internal/InternalCommandPortListeningCheck.java#L29-L38

This is part of the default HostPortWaitStrategy. It might be the case, that the atmoz/sftp:latest does not allow any of those commands to be run.

Testcontainers with sftp image throws Error on "nc not found" or "Address Not Available"

I have this very simple code for running my integration test: (using Testcontainer artifact version 1.16.2) Note: I have tested whether this port in test is available before running the test case. @

Stack Overflow

@talios And

First check if port 2222 is free in the machine that is launching the TestContainer.

Second, change you setup of GenericContainer to:

sftpContainer = new GenericContainer<>(DockerImageName.parse("atmoz/sftp:latest")).withExposedPorts(PORT)
.withCommand("foo:pass:::folder")
.withCreateContainerCmdModifier(
cmd -> cmd.withHostConfig(
new HostConfig()
.withPortBindings(new PortBinding(Ports.Binding.bindPort(22), new ExposedPort(PORT)))));
You need to map the exposed port (in your case 2222) into the internal port (22).

This example run on version 1.16.0 of testcontainers.

@talios In your case 8181 is the problematic port?