Skip to content

Instantly share code, notes, and snippets.

Last active April 10, 2021 13:26
Show Gist options
  • Save 62mkv/ca74f50ea8f77bcc863aaec17cb3e93a to your computer and use it in GitHub Desktop.
Save 62mkv/ca74f50ea8f77bcc863aaec17cb3e93a to your computer and use it in GitHub Desktop.
Hosting FTP in Docker with Docker Desktop under Windows 10

Sneak on docker containers' traffic:

docker run --rm --net=host -v $PWD/tcpdump:/tcpdump kaazing/tcpdump

This will save tcpdump.pcap to tcpdump folder under current directory. That file can be opened with WireShark (sometimes it fails to open the file - check if any concurrent instances of tcpdump container are still running)

Run vsftpd container with mapped volume:

docker run --rm -it -p 21:21 -p 4559-4564:4559-4564 -v c:\temp:/srv -e FTP_USER=ftp -e FTP_PASSWORD=ftp

This will map a c:\temp folder as /srv folder inside the container, i.e. this is the root of folder that is hosted over FTP

@SpringBootTest(classes = [FtpConfiguration::class])
@Disabled("some Permissions issue under Docker Desktop/Windows 10; also, mapping fixed ports could not possibly work in all situations")
class FtpIntTest {
lateinit var ftpFilePublisher: FtpFilePublisher
companion object {
val logger = LoggerFactory.getLogger(
private val ftpContainer = GenericContainer<GenericContainer<*>>(DockerImageName.parse("panubo/vsftpd:latest"))
.withEnv("FTP_USER", "guest")
.withEnv("FTP_PASSWORD", "guest")
.withFileSystemBind("C:\\temp", "/srv", BindMode.READ_WRITE)
.withCreateContainerCmdModifier {
val logConsumer = Slf4jLogConsumer(logger)
fun registerDynamicProperties(registry: DynamicPropertyRegistry) {
registry.add("export.ftp.hostname", ftpContainer::getContainerIpAddress)
registry.add("export.ftp.port") { ftpContainer.getMappedPort(21) }
registry.add("export.ftp.username") { "guest" }
registry.add("export.ftp.password") { "guest" }"hostname {} port {}", ftpContainer.getContainerIpAddress(), ftpContainer.getMappedPort(21))
fun `can publish the file`() {
val inputStream = ByteArrayInputStream("my-file".toByteArray())
ftpFilePublisher.publishFile("","test", inputStream)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment