File tree Expand file tree Collapse file tree
main/java/com/github/dockerjava
test/java/com/github/dockerjava/cmd Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -435,6 +435,10 @@ public interface CreateContainerCmd extends SyncDockerCmd<CreateContainerRespons
435435
436436 CreateContainerCmd withCgroupParent (String cgroupParent );
437437
438+ CreateContainerCmd withGroupAdd (String [] groups );
439+
440+ String [] getGroupAdd ();
441+
438442 /**
439443 * Set the PID (Process) Namespace mode for the container, 'host': use the host's PID namespace inside the container
440444 */
Original file line number Diff line number Diff line change @@ -200,6 +200,8 @@ public class HostConfig implements Serializable {
200200 @ JsonProperty ("PidsLimit" )
201201 private Long pidsLimit ;
202202
203+ @ JsonProperty ("GroupAdd" )
204+ private String [] groupAdd ;
203205
204206 @ JsonIgnore
205207 public Bind [] getBinds () {
@@ -816,6 +818,23 @@ public HostConfig withPidsLimit(Long pidsLimit) {
816818 this .pidsLimit = pidsLimit ;
817819 return this ;
818820 }
821+
822+
823+ /**
824+ * @see #groupAdd
825+ */
826+ @ CheckForNull
827+ public String [] getGroupAdd () {
828+ return groupAdd ;
829+ }
830+
831+ /**
832+ * @see #groupAdd
833+ */
834+ public HostConfig withGroupAdd (String [] groupAdd ) {
835+ this .groupAdd = groupAdd ;
836+ return this ;
837+ }
819838 // end of auto-generated
820839
821840 @ Override
Original file line number Diff line number Diff line change @@ -254,6 +254,12 @@ public String[] getDnsSearch() {
254254 return hostConfig .getDnsSearch ();
255255 }
256256
257+ @ Override
258+ @ JsonIgnore
259+ public String [] getGroupAdd () {
260+ return hostConfig .getGroupAdd ();
261+ }
262+
257263 @ Override
258264 public String getDomainName () {
259265 return domainName ;
@@ -987,6 +993,13 @@ public CreateContainerCmd withHostConfig(HostConfig hostConfig) {
987993 return this ;
988994 }
989995
996+ @ Override
997+ public CreateContainerCmd withGroupAdd (String [] groupAdd ) {
998+ checkNotNull (groupAdd , "groupAdd was not specified" );
999+ this .hostConfig .withGroupAdd (groupAdd );
1000+ return this ;
1001+ }
1002+
9901003 @ Override
9911004 public String toString () {
9921005 return ToStringBuilder .reflectionToString (this );
Original file line number Diff line number Diff line change @@ -823,4 +823,23 @@ public void createContainerWithNetworkID() {
823823 }
824824 assertThat (containerNetwork , notNullValue ());
825825 }
826+
827+ @ Test
828+ public void createContainerWithGroupAdd () throws DockerException {
829+ String [] groupsToAdd = {"www-data" };
830+
831+ CreateContainerResponse container = dockerRule .getClient ().createContainerCmd (DEFAULT_IMAGE )
832+ .withGroupAdd (groupsToAdd )
833+ .withCmd ("true" ).exec ();
834+
835+ LOG .info ("Created container {}" , container .toString ());
836+
837+ assertThat (container .getId (), not (isEmptyString ()));
838+
839+ InspectContainerResponse inspectContainerResponse = dockerRule .getClient ().inspectContainerCmd (container .getId ()).exec ();
840+
841+ LOG .info ("Inspect container {}" , Arrays .toString (inspectContainerResponse .getHostConfig ().getGroupAdd ()));
842+
843+ assertThat (inspectContainerResponse .getHostConfig ().getGroupAdd (), is (groupsToAdd ));
844+ }
826845}
You can’t perform that action at this time.
0 commit comments