Skip to content

Commit 3e00a59

Browse files
author
Christopher Dancy
committed
REMOVED: 'json-file' default as this is redundant.
ADDED: documentation on how to use LogConfig and its available drivers. ADDED: fleshed out LogConfig support to be more in line with other options.
1 parent dc8b025 commit 3e00a59

File tree

3 files changed

+51
-9
lines changed

3 files changed

+51
-9
lines changed

src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.github.dockerjava.api.model.ExposedPort;
1111
import com.github.dockerjava.api.model.HostConfig;
1212
import com.github.dockerjava.api.model.Link;
13+
import com.github.dockerjava.api.model.LogConfig;
1314
import com.github.dockerjava.api.model.LxcConf;
1415
import com.github.dockerjava.api.model.PortBinding;
1516
import com.github.dockerjava.api.model.Ports;
@@ -88,6 +89,8 @@ public static interface Exec extends DockerCmdSyncExec<CreateContainerCmd, Creat
8889
public Link[] getLinks();
8990

9091
public LxcConf[] getLxcConf();
92+
93+
public LogConfig getLogConfig();
9194

9295
public String getMacAddress();
9396

@@ -224,6 +227,8 @@ public static interface Exec extends DockerCmdSyncExec<CreateContainerCmd, Creat
224227

225228
public CreateContainerCmd withLxcConf(LxcConf... lxcConf);
226229

230+
public CreateContainerCmd withLogConfig(LogConfig logConfig);
231+
227232
public CreateContainerCmd withMemoryLimit(long memoryLimit);
228233

229234
public CreateContainerCmd withMemorySwap(long memorySwap);
Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
11
package com.github.dockerjava.api.model;
22

3-
import java.util.List;
3+
import java.util.Map;
44

55
import com.fasterxml.jackson.annotation.JsonIgnore;
66
import com.fasterxml.jackson.annotation.JsonProperty;
77

8+
/**
9+
* Log driver to use for a created/running container. The
10+
* available types are:
11+
*
12+
* json-file (default)
13+
* syslog
14+
* journald
15+
* none
16+
*
17+
* If a driver is specified that is NOT supported,docker
18+
* will default to null. If configs are supplied that are
19+
* not supported by the type docker will ignore them. In most
20+
* cases setting the config option to null will suffice. Consult
21+
* the docker remote API for a more detailed and up-to-date
22+
* explanation of the available types and their options.
23+
*/
824
public class LogConfig {
925

1026
@JsonProperty("Type")
11-
public String type = "json-file";
27+
public String type;
1228

1329
@JsonProperty("Config")
14-
public List<String> config = null;
30+
public Map<String, String> config;
1531

16-
public LogConfig(String type) {
32+
public LogConfig(String type, Map<String, String> config) {
1733
this.type = type;
34+
this.config = config;
1835
}
1936

2037
public LogConfig() {
@@ -23,14 +40,20 @@ public LogConfig() {
2340
public String getType() {
2441
return type;
2542
}
26-
27-
@JsonIgnore
28-
public List<String> getConfig() {
29-
return config;
30-
}
3143

3244
public LogConfig setType(String type) {
3345
this.type = type;
3446
return this;
3547
}
48+
49+
@JsonIgnore
50+
public Map<String, String> getConfig() {
51+
return config;
52+
}
53+
54+
@JsonIgnore
55+
public LogConfig setConfig(Map<String, String> config) {
56+
this.config = config;
57+
return this;
58+
}
3659
}

src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.github.dockerjava.api.model.ExposedPorts;
2020
import com.github.dockerjava.api.model.HostConfig;
2121
import com.github.dockerjava.api.model.Link;
22+
import com.github.dockerjava.api.model.LogConfig;
2223
import com.github.dockerjava.api.model.LxcConf;
2324
import com.github.dockerjava.api.model.PortBinding;
2425
import com.github.dockerjava.api.model.Ports;
@@ -269,6 +270,12 @@ public Map<String, String> getLabels() {
269270
public LxcConf[] getLxcConf() {
270271
return hostConfig.getLxcConf();
271272
}
273+
274+
@Override
275+
@JsonIgnore
276+
public LogConfig getLogConfig() {
277+
return hostConfig.getLogConfig();
278+
}
272279

273280
public String getMacAddress() {
274281
return macAddress;
@@ -558,6 +565,13 @@ public CreateContainerCmd withLxcConf(LxcConf... lxcConf) {
558565
this.hostConfig.setLxcConf(lxcConf);
559566
return this;
560567
}
568+
569+
@Override
570+
public CreateContainerCmd withLogConfig(LogConfig logConfig) {
571+
checkNotNull(logConfig, "logConfig was not specified");
572+
this.hostConfig.setLogConfig(logConfig);
573+
return this;
574+
}
561575

562576
@Override
563577
public CreateContainerCmdImpl withMacAddress(String macAddress) {

0 commit comments

Comments
 (0)