- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 583
 
chore: support for deciding when to auto-export the image ports in case no exposed ports are passed #3159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            mdelapenya
  wants to merge
  15
  commits into
  testcontainers:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
mdelapenya:fix-do-not-expose-ports-from-image
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
                
     Open
            
            chore: support for deciding when to auto-export the image ports in case no exposed ports are passed #3159
                    mdelapenya
  wants to merge
  15
  commits into
  testcontainers:main
from
mdelapenya:fix-do-not-expose-ports-from-image
  
      
      
   
              
            
      
        
          +176
        
        
          −53
        
        
          
        
      
    
  
Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    It's covered by a tc property, so it's not a breaking change
          ✅ Deploy Preview for testcontainers-go ready!
 To edit notification comments on pull requests, go to your Netlify project configuration.  | 
    
…ners#3161) * feat: add a new functional option to append wait strategies to modules * chore: update modules * docs: make it mkore clear
* main: feat(couchbase): adding auth to couchbase initCluster functions to support container reuse (testcontainers#3048) chore(deps): bump github.com/containerd/containerd/v2 (testcontainers#3167) docs(options): refactor options layout in modules (testcontainers#3163) fix(ci): do not run sonar for Testcontainers Cloud (testcontainers#3166) chore(ci): do not fail fast in the Testcontainers Cloud run (testcontainers#3164) feat: support adding wait strategies as functional option (testcontainers#3161)
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
What does this PR do?
This PR adds support for enabling/disabling auto-exposing the port from the container image (default is true: ports are automatically exposed).
This new setting can be configured at the properties level (using the
tc.auto.expose.portsproperty) or with an env var (TESTCONTAINERS_AUTO_EXPOSE_PORTS).When set to true, which is the default, the exposed ports in the image are automatically exposed to the container. When set to false, they are not.
This behavior was present in tc-java in the past (basically
-Pflag, publish all exposed ports), but we removed it, because it created bugs on Windows with running out of ports in a specific range over time. Given that bug is still open in Docker for Windows, we decided to not publish all ports, or at least let users configure it.On the other hand, we are simplifying the auto-exposure of all the ports: instead of inspecting the image and merging the ports with the user request, we set the
PublishAllPortsoption to true in the hostConfig modifier.Why is it important?
Simplify code, and also reduce the chances to get the bug described in docker/for-win#11584
Related issues