Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion core/src/main/java/org/testcontainers/containers/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ default void addFileSystemBind(final String hostPath, final String containerPath
void addFileSystemBind(String hostPath, String containerPath, BindMode mode, SelinuxContext selinuxContext);

/**
* Add a link to another container.
* Add a link to another container. Consider using {@link #withLink(LinkableContainer, String)}
* for building a container in a fluent style.
*
* @param otherContainer the other container object to link to
* @param alias the alias (for the other container) that this container should be able to use
Expand Down Expand Up @@ -151,6 +152,14 @@ default void addFileSystemBind(final String hostPath, final String containerPath
*/
SELF withVolumesFrom(Container container, BindMode mode);

/**
* Add a link to another container.
*
* @param otherContainer the other container object to link to
* @param alias the alias (for the other container) that this container should be able to use
*/
SELF withLink(LinkableContainer otherContainer, String alias);

/**
* Set the ports that this container listens on
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,12 @@ public SELF withVolumesFrom(Container container, BindMode mode) {
return self();
}

@Override
public SELF withLink(LinkableContainer otherContainer, String alias) {
addLink(otherContainer, alias);
return self();
}

private void addVolumesFrom(Container container, BindMode mode) {
volumesFroms.add(new VolumesFrom(container.getContainerName(), mode.accessMode));
}
Expand Down