Skip to content

[Bug]: Inline env variable doesn't work in "execInContainer" #7651

Description

@gredwhite

Module

Core

Testcontainers version

1.18.3

Using the latest Testcontainers version?

Yes

Host OS

Windows

Host Arch

x64

Docker version

Docker version 24.0.6, build ed223bc

What happened?

In my docker desktop I execute this command successfully:

LDB_MODULES_PATH=/usr/lib/samba/ldb/ ldbmodify -H /var/lib/samba/private/sam.ldb /tmp/test.ldif 
Modified 0 records successfully

I want to do the same in testcontainers:

SAMBA_IMAGE = "instantlinux/samba-dc:4.18.5-r0"
val sambaContainer = GenericContainer(SAMBA_IMAGE)
....
sambaContainer.execInContainer(
            "LDB_MODULES_PATH=/usr/lib/samba/ldb/",
            "ldbmodify",
            "-H",
           "/var/lib/samba/private/sam.ldb",
            "/tmp/test.ldif",
        )

But I get the error:

OCI runtime exec failed: exec failed: unable to start container process: exec: "LDB_MODULES_PATH=/usr/lib/samba/ldb/": stat LDB_MODULES_PATH=/usr/lib/samba/ldb/: no such file or directory: unknown

I've found the workaround:

val sambaContainer = GenericContainer(SAMBA_IMAGE)
                     ...
                    .withEnv("LDB_MODULES_PATH","/usr/lib/samba/ldb/")
sambaContainer.start()
sambaContainer.execInContainer(
                "ldbmodify",
                "-H",
               "/var/lib/samba/private/sam.ldb",
                "/tmp/test.ldif",
            )

But I still think that my initial attempt should work.

Relevant log output

No response

Additional Information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions