allow CreateContainer to specify NetworkConfig by nbrugger-tgm · Pull Request #2556 · docker-java/docker-java
Repository navigation
allow CreateContainer to specify NetworkConfig - #2556
Open
nbrugger-tgm wants to merge 1 commit into docker-java:main from nbrugger-tgm:main
Open
allow CreateContainer to specify NetworkConfig #2556 nbrugger-tgm wants to merge 1 commit into docker-java:main from nbrugger-tgm:main
Conversation
nbrugger-tgm commented Dec 8, 2025 · edited by marcuslinke Loading
Copy link Copy Markdown
Closes : #2555
This change is
feat: CreateContainer command exposes NetworkConfig
21f7e5e
nbrugger-tgm
requested a review
from a team
as a code owner
December 8, 2025 22:49
eddumelendez
changed the title
feat: allow CreateContainer to specify NetworkConfig
allow CreateContainer to specify NetworkConfig
Dec 9, 2025
eddumelendez
requested a review
from Copilot
March 21, 2026 00:39
Copilot started reviewing on behalf of
eddumelendez
March 21, 2026 00:40
View session
Copilot PR reviewer Copilot
AI
reviewed Mar 21, 2026
View reviewed changes
Copilot
AI
left a comment
Copy link Copy Markdown
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Pull request overview
Adds support for specifying Docker's NetworkingConfig when creating a container, enabling attachment to multiple networks at creation time (per #2555 ).
Changes:
- Introduces a new public API model
com.github.dockerjava.api.model.NetworkingConfig. - Exposes
getNetworkingConfig()/withNetworkingConfig(...)onCreateContainerCmd. - Updates
CreateContainerCmdImpl#exec()to merge endpoint settings instead of overwriting them.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| docker-java-core/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java | Adds networkingConfig accessors and changes exec() to merge endpoint configs rather than replace them. |
| docker-java-api/src/main/java/com/github/dockerjava/api/model/NetworkingConfig.java | Adds a new API model for Docker NetworkingConfig. |
| docker-java-api/src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java | Exposes networkingConfig getter/setter on the public command interface. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started .
Comment thread docker-java-core/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java| if (containerNetwork != null && hostConfig.getNetworkMode() != null) { | ||
| networkingConfig = new NetworkingConfig() | ||
| .withEndpointsConfig(singletonMap(hostConfig.getNetworkMode(), containerNetwork)); | ||
| // If the user explicitly sets networkingConfig or endpointConfig to null, its reasonable to not overwrite it |
| if (containerNetwork != null && hostConfig.getNetworkMode() != null) { | ||
| networkingConfig = new NetworkingConfig() | ||
| .withEndpointsConfig(singletonMap(hostConfig.getNetworkMode(), containerNetwork)); | ||
| // If the user explicitly sets networkingConfig or endpointConfig to null, its reasonable to not overwrite it | ||
| if (networkingConfig != null | ||
| && networkingConfig.getEndpointsConfig() != null | ||
| && !networkingConfig.getEndpointsConfig().containsKey(hostConfig.getNetworkMode()) | ||
| ) { | ||
| networkingConfig.getEndpointsConfig().put(hostConfig.getNetworkMode(), containerNetwork); | ||
| } |
| // If the user explicitly sets networkingConfig or endpointConfig to null, its reasonable to not overwrite it | ||
| if (networkingConfig != null | ||
| && networkingConfig.getEndpointsConfig() != null | ||
| && !networkingConfig.getEndpointsConfig().containsKey(hostConfig.getNetworkMode()) | ||
| ) { |
| public class NetworkingConfig { | ||
|
|
||
| public NetworkingConfig() { | ||
| this.endpointsConfig = new HashMap<>(); | ||
| } | ||
| public NetworkingConfig(Map<String, ContainerNetwork> endpointsConfig) { | ||
| this.endpointsConfig = endpointsConfig; | ||
| } |
| if (containerNetwork != null && hostConfig.getNetworkMode() != null) { | ||
| networkingConfig = new NetworkingConfig() | ||
| .withEndpointsConfig(singletonMap(hostConfig.getNetworkMode(), containerNetwork)); | ||
| // If the user explicitly sets networkingConfig or endpointConfig to null, its reasonable to not overwrite it | ||
| if (networkingConfig != null | ||
| && networkingConfig.getEndpointsConfig() != null | ||
| && !networkingConfig.getEndpointsConfig().containsKey(hostConfig.getNetworkMode()) | ||
| ) { | ||
| networkingConfig.getEndpointsConfig().put(hostConfig.getNetworkMode(), containerNetwork); | ||
| } |
KostyaSha commented Nov 20, 2026
Copy link Copy Markdown
Member
|
Hi, what is the status? |
nbrugger-tgm commented Nov 20, 2026
Copy link Copy Markdown
Author
Hi sorry i didn't notice the review of copilot. There are strange things such as the missing import and the code not compiling, it seems i forgot a commit. I will put it on my calendar to fix the mentioned issues |