testcontainers-rs icon indicating copy to clipboard operation
testcontainers-rs copied to clipboard

[Feature] Add tty option

Open asaphaaning opened this issue 3 years ago • 13 comments

Thanks for branching this wonderful project out into the Rust space!

Some images rely on a tty being available to properly function. This should cover it!

asaphaaning avatar May 25 '22 18:05 asaphaaning

Can you provide an example docker image that requires docker to have a pseudo-tty configured? So this can be verified. I am not 100% sure this works with stdout piped https://github.com/testcontainers/testcontainers-rs/blob/dev/testcontainers/src/clients/cli.rs#L188 this is why i ask

mfelsche avatar Jun 09 '22 12:06 mfelsche

I can't quite reproduce the image (some php + openrc stuff) I was working with but essentially it looked like the snippet below, symlinking from the tty over to the log locations and expecting /dev/pts/0 to be writable.

Example

FROM nginx:stable-alpine

COPY init.sh /

RUN ln -nsf /dev/pts/1 /var/log/nginx/access.log

ENTRYPOINT ["/init.sh"]

init.sh

chmod o+w /dev/pts/1

I tested my changes with the image and confirmed that running with -it allows the container to boot.

asaphaaning avatar Jun 09 '22 21:06 asaphaaning

Thanks! Maintaining a minimal API is something that is really important, hence a couple of questions:

  • Would it hurt to always try and allocate a tty and not expose this config option at all?
  • The option seems to be image specific so I think we can remove the override on RunnableImage?
  • It would be nice to add a test-case with an actual docker image for such purposes. You can add them here so they are available within the test-suite!

thomaseizinger avatar Jun 22 '22 07:06 thomaseizinger

Hi @thomaseizinger!

Thanks for putting this thing together!

I actually do agree that having ptty available is a sensible default. If I flip the bit in the trait default implementation the implementing party will not be required to override it while leaving the the option there if they specifically want to not allocate a ptty. What do you think?

I added a test case too as per request 👍

asaphaaning avatar Jul 01 '22 09:07 asaphaaning

@thomaseizinger

Anything else you'd like me to cover? :)

asaphaaning avatar Jul 27 '22 12:07 asaphaaning

:v: ASAPHAANING can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

bors[bot] avatar Jul 29 '22 10:07 bors[bot]

bors r+

asaphaaning avatar Aug 09 '22 12:08 asaphaaning

Timed out.

bors[bot] avatar Aug 09 '22 13:08 bors[bot]

bors retry

thomaseizinger avatar Aug 09 '22 17:08 thomaseizinger

Timed out.

bors[bot] avatar Aug 09 '22 18:08 bors[bot]

bors retry

I think the test_ipv4_ipv6_host_ports test is broken on dev. I can make the entire suite run if I comment out the ipv6 assertions.

asaphaaning avatar Aug 09 '22 20:08 asaphaaning

bors retry

I think the test_ipv4_ipv6_host_ports test is broken on dev. I can make the entire suite run if I comment out the ipv6 assertions.

Damn. Thanks for investigating. I'll see to look into this in more detail but it will be a while as I am traveling for the next two weeks.

thomaseizinger avatar Aug 16 '22 08:08 thomaseizinger

Timed out.

bors[bot] avatar Sep 01 '22 11:09 bors[bot]

We've released a new version of testcontainers: 0.16.0.

Could you update and re-open the PR if it's still relevant.

Closing because of inactivity for now

DDtKey avatar Apr 28 '24 18:04 DDtKey