question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose docker.from_env() parameters

See original GitHub issue

testcontainers.core.DockerClient calls docker.from_env() it it’s constructor. This method has a few parameters that will be useful to be exposed (see reference)

Ideally testcontainers.core.DockerClient and conversely testcontainers.core.DockerContainer should expose these parameters.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
tillahoffmanncommented, Apr 27, 2022

So basically, we can add **kwargs to the DockerClient constructor and pass that to the .from_env method. Similarly, in the DockerContainer class, we can pass the kwargs to the DockerClient.

That sounds reasonable. But let’s pass a dictionary docker_client_kw to DockerContainer and then unpack the dictionary in the call to DockerClient akin to gridspec_kw matplotlib.pyplot.subplots.

0reactions
thedrowcommented, Apr 26, 2022

I think it could be useful to implement it this way but it doesn’t really abstract the Docker client which isn’t bad per-se if the project’s scope is limited only to Docker and not other kind of containers (BSD Jails could be useful for example). However, we do need to consider that we might switch from the official docker client at some point since it may be phased out or since Docker Inc will unexpectedly go bankrupt etc.

I admit these risks are rather minor, but violating encapsulation needs better reasons than useful.

The design we’re looking for is the ability to pass a ContainerClientConfiguration object which we can use for testing by mocking the object, provide configuration to multiple container implementations and maybe something I haven’t thought of.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dockerfile reference - Docker Documentation
The FROM instruction specifies the Parent Image from which you are building. FROM may only be preceded by one or more ARG instructions,...
Read more >
How do I pass environment variables to Docker containers?
The docker run command just reads the file, does very basic parsing and passes the values through to the container, it's not equivalent...
Read more >
Expose Pod Information to Containers Through Environment ...
Use Pod fields as values for environment variables. In this part of exercise, you create a Pod that has one container, and you...
Read more >
Environment variables are not applied on container build #1837
I see no options to pass env vars from .env.local to build context (( ... I really like the docker syntax and using...
Read more >
How can I use environment variables in Nginx.conf
To avoid a very complex command parameter to the container (as in the linked example), you can write a Docker entrypoint script which...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found