Repository: docker-java/docker-java
Pull request #193 (2015-04-07 19:09:40)

Add HostConfig related methods from start command to create command


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c1b319a7..a033ccb4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,11 +1,6 @@
 Change Log
 ===
 Latest SNAPSHOT
----
-
-* [#192](https://github.com/docker-java/docker-java/pull/192) Added a Links constructor accepting a List object
-
-v1.1.0
 ---
  
  * [#186](https://github.com/docker-java/docker-java/pull/186) Added withPull method to BuilImageCmd 
diff --git a/pom.xml b/pom.xml
index 957c157c..ba60602a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
 	<groupId>com.github.docker-java</groupId>
 	<artifactId>docker-java</artifactId>
 	<packaging>jar</packaging>
-	<version>1.1.1-SNAPSHOT</version>
+	<version>1.0.1-SNAPSHOT</version>
 
 	<name>docker-java</name>
 	<url>https://github.com/docker-java/docker-java</url>
diff --git a/src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java b/src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java
index c6a1234c..a2a6dc85 100644
--- a/src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java
+++ b/src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java
@@ -2,111 +2,115 @@ package com.github.dockerjava.api.command;
 
 import com.github.dockerjava.api.ConflictException;
 import com.github.dockerjava.api.NotFoundException;
+import com.github.dockerjava.api.model.Bind;
 import com.github.dockerjava.api.model.Capability;
+import com.github.dockerjava.api.model.Device;
 import com.github.dockerjava.api.model.ExposedPort;
 import com.github.dockerjava.api.model.HostConfig;
+import com.github.dockerjava.api.model.Link;
+import com.github.dockerjava.api.model.LxcConf;
+import com.github.dockerjava.api.model.PortBinding;
+import com.github.dockerjava.api.model.Ports;
+import com.github.dockerjava.api.model.RestartPolicy;
 import com.github.dockerjava.api.model.Volume;
 import com.github.dockerjava.api.model.VolumesFrom;
 
 public interface CreateContainerCmd extends DockerCmd<CreateContainerResponse>{
 
-	public CreateContainerCmd withName(String name);
-
-	public String getName();
-
-	public CreateContainerCmd withExposedPorts(ExposedPort... exposedPorts);
-
-	public ExposedPort[] getExposedPorts();
+	public static interface Exec extends DockerCmdExec<CreateContainerCmd, CreateContainerResponse> {
+	}
 
-	public boolean isDisableNetwork();
+	/**
+	 * @throws NotFoundException No such container
+	 * @throws ConflictException Named container already exists
+	 */
+    @Override
+	public CreateContainerResponse exec() throws NotFoundException,
+			ConflictException;
 
-	public String getWorkingDir();
+	public Bind[] getBinds();
 
-	public CreateContainerCmd withWorkingDir(String workingDir);
+	public Capability[] getCapAdd();
 
-	public String getHostName();
+	public Capability[] getCapDrop();
 
-	public CreateContainerCmd withDisableNetwork(boolean disableNetwork);
+	public String[] getCmd();
 
-	public CreateContainerCmd withHostName(String hostName);
+	public String getCpuset();
 
-	public String[] getPortSpecs();
+	public int getCpuShares();
 
-	public CreateContainerCmd withPortSpecs(String... portSpecs);
+	public Device[] getDevices();
 
-	public String getUser();
+	public String[] getDns();
+	
+	public String[] getDnsSearch();
 
-	public CreateContainerCmd withUser(String user);
+	public String[] getEntrypoint();
 
-	public boolean isTty();
+	public String[] getEnv();
 
-	public CreateContainerCmd withTty(boolean tty);
+	public ExposedPort[] getExposedPorts();
+	
+	public String[] getExtraHosts();
 
-	public boolean isStdinOpen();
+	public HostConfig getHostConfig();
 
-	public CreateContainerCmd withStdinOpen(boolean stdinOpen);
+	public String getHostName();
 
-	public boolean isStdInOnce();
+	public String getImage();
 
-	public CreateContainerCmd withStdInOnce(boolean stdInOnce);
+	public Link[] getLinks();
+	
+	public LxcConf[] getLxcConf();
 
 	public long getMemoryLimit();
 
-	public CreateContainerCmd withMemoryLimit(long memoryLimit);
-
 	public long getMemorySwap();
 
-	public CreateContainerCmd withMemorySwap(long memorySwap);
-
-	public int getCpuShares();
-
-	public CreateContainerCmd withCpuShares(int cpuShares);
-
-	public String getCpuset();
+	public String getName();
+	
+	public String getNetworkMode();
+	
+	public Ports getPortBindings();
 
-	public CreateContainerCmd withCpuset(String cpuset);
+	public String[] getPortSpecs();
+	
+	public RestartPolicy getRestartPolicy();
 
-	public boolean isAttachStdin();
+	public String getUser();
 
-	public CreateContainerCmd withAttachStdin(boolean attachStdin);
+	public Volume[] getVolumes();
 
-	public boolean isAttachStdout();
+	public VolumesFrom[] getVolumesFrom();
 
-	public CreateContainerCmd withAttachStdout(boolean attachStdout);
+	public String getWorkingDir();
 
 	public boolean isAttachStderr();
 
-	public CreateContainerCmd withAttachStderr(boolean attachStderr);
-
-	public String[] getEnv();
-
-	public CreateContainerCmd withEnv(String... env);
-
-	public String[] getCmd();
-
-	public CreateContainerCmd withCmd(String... cmd);
-
-	public String[] getDns();
+	public boolean isAttachStdin();
 
-	public CreateContainerCmd withDns(String... dns);
+	public boolean isAttachStdout();
 
-	public String getImage();
+	public boolean isDisableNetwork();
+	
+	public Boolean isPrivileged();
+	
+	public Boolean isPublishAllPorts();
 
-	public CreateContainerCmd withImage(String image);
+	public boolean isStdInOnce();
 
-	public Volume[] getVolumes();
+	public boolean isStdinOpen();
 
-	public CreateContainerCmd withVolumes(Volume... volumes);
+	public boolean isTty();
 
-	public VolumesFrom[] getVolumesFrom();
+	public CreateContainerCmd withAttachStderr(boolean attachStderr);
 
-	public CreateContainerCmd withVolumesFrom(VolumesFrom... volumesFrom);
+	public CreateContainerCmd withAttachStdin(boolean attachStdin);
 	
-	public HostConfig getHostConfig();
+	public CreateContainerCmd withAttachStdout(boolean attachStdout);
 	
-	public CreateContainerCmd withHostConfig(HostConfig hostConfig);
-
-	public Capability[] getCapAdd();
+	public CreateContainerCmd withBinds(Bind... binds);
 
 	/**
 	 * Add linux <a
@@ -116,8 +120,6 @@ public interface CreateContainerCmd extends DockerCmd<CreateContainerResponse>{
 	 */
 	public CreateContainerCmd withCapAdd(Capability... capAdd);
 
-	public Capability[] getCapDrop();
-
 	/**
 	 * Drop linux <a
 	 * href="http://man7.org/linux/man-pages/man7/capabilities.7.html">kernel
@@ -125,21 +127,114 @@ public interface CreateContainerCmd extends DockerCmd<CreateContainerResponse>{
 	 * prevents the container from changing the owner of any files.
 	 */
 	public CreateContainerCmd withCapDrop(Capability... capDrop);
+
+	public CreateContainerCmd withCmd(String... cmd);
+
+	public CreateContainerCmd withCpuset(String cpuset);
 	
+	public CreateContainerCmd withCpuShares(int cpuShares);
 	
-	public String[] getEntrypoint();
+	/**
+	 * Add host devices to the container
+	 */
+	public CreateContainerCmd withDevices(Device... devices);
+
+	public CreateContainerCmd withDisableNetwork(boolean disableNetwork);
+
+	/**
+	 * Set custom DNS servers
+	 */
+	public CreateContainerCmd withDns(String... dns);
 	
+	/**
+	 * Set custom DNS search domains
+	 */
+	public CreateContainerCmd withDnsSearch(String... dnsSearch);
+
 	public CreateContainerCmd withEntrypoint(String... entrypoint);
+
+	public CreateContainerCmd withEnv(String... env);
+	
+	public CreateContainerCmd withExposedPorts(ExposedPort... exposedPorts);
 	
 	/**
-	 * @throws NotFoundException No such container
-	 * @throws ConflictException Named container already exists
+	 * Add hostnames to /etc/hosts in the container
 	 */
-    @Override
-	public CreateContainerResponse exec() throws NotFoundException,
-			ConflictException;
+	public CreateContainerCmd withExtraHosts(String... extraHosts);
 	
-	public static interface Exec extends DockerCmdExec<CreateContainerCmd, CreateContainerResponse> {
-	}
+	public CreateContainerCmd withHostConfig(HostConfig hostConfig);
+
+	public CreateContainerCmd withHostName(String hostName);
+
+	public CreateContainerCmd withImage(String image);
+
+	/**
+	 * Add link to another container.
+	 */
+	public CreateContainerCmd withLinks(Link... links);
+	
+	public CreateContainerCmd withLxcConf(LxcConf... lxcConf);
+
+	public CreateContainerCmd withMemoryLimit(long memoryLimit);
+	
+	public CreateContainerCmd withMemorySwap(long memorySwap);
+	
+	public CreateContainerCmd withName(String name);
+	
+
+	/**
+	 * Set the Network mode for the container
+	 * <ul>
+	 * <li>'bridge': creates a new network stack for the container on the docker
+	 * bridge</li>
+	 * <li>'none': no networking for this container</li>
+	 * <li>'container:<name|id>': reuses another container network stack</li>
+	 * <li>'host': use the host network stack inside the container. Note: the
+	 * host mode gives the container full access to local system services such
+	 * as D-bus and is therefore considered insecure.</li>
+	 * </ul>
+	 */
+	public CreateContainerCmd withNetworkMode(String networkMode);
+	
+	/**
+	 * Add one or more {@link PortBinding}s.
+	 * This corresponds to the <code>--publish</code> (<code>-p</code>)
+	 * option of the <code>docker run</code> CLI command.
+	 */
+	public CreateContainerCmd withPortBindings(PortBinding... portBindings);
+	
+	/**
+	 * Add the port bindings that are contained in the given {@link Ports}
+	 * object.
+	 * 
+	 * @see #withPortBindings(PortBinding...)
+	 */
+	public CreateContainerCmd withPortBindings(Ports portBindings);
+
+	public CreateContainerCmd withPortSpecs(String... portSpecs);
+	
+	public CreateContainerCmd withPrivileged(boolean privileged);
+	
+	public CreateContainerCmd withPublishAllPorts(boolean publishAllPorts);
+	
+	/**
+	 * Set custom {@link RestartPolicy} for the container. Defaults to
+	 * {@link RestartPolicy#noRestart()}
+	 */
+	public CreateContainerCmd withRestartPolicy(RestartPolicy restartPolicy);
+
+	public CreateContainerCmd withStdInOnce(boolean stdInOnce);
+
+	public CreateContainerCmd withStdinOpen(boolean stdinOpen);
+
+	public CreateContainerCmd withTty(boolean tty);
+		
+	public CreateContainerCmd withUser(String user);
+	
+	public CreateContainerCmd withVolumes(Volume... volumes);
+	
+	public CreateContainerCmd withVolumesFrom(VolumesFrom... volumesFrom);
+	
+	public CreateContainerCmd withWorkingDir(String workingDir);
 
 }
diff --git a/src/main/java/com/github/dockerjava/api/command/StartContainerCmd.java b/src/main/java/com/github/dockerjava/api/command/StartContainerCmd.java
index de70b97c..e76598e3 100644
--- a/src/main/java/com/github/dockerjava/api/command/StartContainerCmd.java
+++ b/src/main/java/com/github/dockerjava/api/command/StartContainerCmd.java
@@ -18,72 +18,79 @@ import com.github.dockerjava.api.model.RestartPolicy;
  */
 public interface StartContainerCmd extends DockerCmd<Void> {
 
-	public Bind[] getBinds();
+	public static interface Exec extends DockerCmdExec<StartContainerCmd, Void> {
+	}
 
-	public Link[] getLinks();
+	/**
+	 * @throws NotFoundException
+	 *             No such container
+	 * @throws NotModifiedException
+	 *             Container already started
+	 */
+	@Override
+	public Void exec() throws NotFoundException, NotModifiedException;
 
-	public LxcConf[] getLxcConf();
+	public Bind[] getBinds();
 
-	public Ports getPortBindings();
+	public Capability[] getCapAdd();
 
-	public Boolean isPublishAllPorts();
+	public Capability[] getCapDrop();
 
-	public Boolean isPrivileged();
+	public String getContainerId();
+
+	public Device[] getDevices();
 
 	public String[] getDns();
 
 	public String[] getDnsSearch();
 
-	public String getVolumesFrom();
+	public String[] getExtraHosts();
 
-	public String getContainerId();
+	public Link[] getLinks();
 
-	public String getNetworkMode();
+	public LxcConf[] getLxcConf();
 
-	public Device[] getDevices();
+	public String getNetworkMode();
 
-	public String[] getExtraHosts();
+	public Ports getPortBindings();
 
 	public RestartPolicy getRestartPolicy();
 
-	public Capability[] getCapAdd();
-
-	public Capability[] getCapDrop();
+	public String getVolumesFrom();
 
-	@Deprecated
-	public StartContainerCmd withBinds(Bind... binds);
+	public Boolean isPrivileged();
 
-	/**
-	 * Add link to another container.
-	 */
-	@Deprecated
-	public StartContainerCmd withLinks(Link... links);
+	public Boolean isPublishAllPorts();
 
 	@Deprecated
-	public StartContainerCmd withLxcConf(LxcConf... lxcConf);
+	public StartContainerCmd withBinds(Bind... binds);
 
 	/**
-	 * Add the port bindings that are contained in the given {@link Ports}
-	 * object.
-	 * 
-	 * @see #withPortBindings(PortBinding...)
+	 * Add linux <a
+	 * href="http://man7.org/linux/man-pages/man7/capabilities.7.html">kernel
+	 * capability</a> to the container. For example: adding {@link Capability#MKNOD}
+	 * allows the container to create special files using the 'mknod' command.
 	 */
 	@Deprecated
-	public StartContainerCmd withPortBindings(Ports portBindings);
+	public StartContainerCmd withCapAdd(Capability... capAdd);
 
 	/**
-	 * Add one or more {@link PortBinding}s.
-	 * This corresponds to the <code>--publish</code> (<code>-p</code>)
-	 * option of the <code>docker run</code> CLI command.
+	 * Drop linux <a
+	 * href="http://man7.org/linux/man-pages/man7/capabilities.7.html">kernel
+	 * capability</a> from the container. For example: dropping {@link Capability#CHOWN}
+	 * prevents the container from changing the owner of any files.
 	 */
 	@Deprecated
-	public StartContainerCmd withPortBindings(PortBinding... portBindings);
+	public StartContainerCmd withCapDrop(Capability... capDrop);
 
 	@Deprecated
-	public StartContainerCmd withPrivileged(Boolean privileged);
+	public StartContainerCmd withContainerId(String containerId);
 
+	/**
+	 * Add host devices to the container
+	 */
 	@Deprecated
-	public StartContainerCmd withPublishAllPorts(Boolean publishAllPorts);
+	public StartContainerCmd withDevices(Device... devices);
 
 	/**
 	 * Set custom DNS servers
@@ -97,11 +104,20 @@ public interface StartContainerCmd extends DockerCmd<Void> {
 	@Deprecated
 	public StartContainerCmd withDnsSearch(String... dnsSearch);
 
+	/**
+	 * Add hostnames to /etc/hosts in the container
+	 */
 	@Deprecated
-	public StartContainerCmd withVolumesFrom(String volumesFrom);
+	public StartContainerCmd withExtraHosts(String... extraHosts);
 
+	/**
+	 * Add link to another container.
+	 */
 	@Deprecated
-	public StartContainerCmd withContainerId(String containerId);
+	public StartContainerCmd withLinks(Link... links);
+
+	@Deprecated
+	public StartContainerCmd withLxcConf(LxcConf... lxcConf);
 
 	/**
 	 * Set the Network mode for the container
@@ -119,52 +135,36 @@ public interface StartContainerCmd extends DockerCmd<Void> {
 	public StartContainerCmd withNetworkMode(String networkMode);
 
 	/**
-	 * Add host devices to the container
+	 * Add one or more {@link PortBinding}s.
+	 * This corresponds to the <code>--publish</code> (<code>-p</code>)
+	 * option of the <code>docker run</code> CLI command.
 	 */
 	@Deprecated
-	public StartContainerCmd withDevices(Device... devices);
+	public StartContainerCmd withPortBindings(PortBinding... portBindings);
 
 	/**
-	 * Add hostnames to /etc/hosts in the container
+	 * Add the port bindings that are contained in the given {@link Ports}
+	 * object.
+	 * 
+	 * @see #withPortBindings(PortBinding...)
 	 */
 	@Deprecated
-	public StartContainerCmd withExtraHosts(String... extraHosts);
+	public StartContainerCmd withPortBindings(Ports portBindings);
 
-	/**
-	 * Set custom {@link RestartPolicy} for the container. Defaults to
-	 * {@link RestartPolicy#noRestart()}
-	 */
 	@Deprecated
-	public StartContainerCmd withRestartPolicy(RestartPolicy restartPolicy);
+	public StartContainerCmd withPrivileged(Boolean privileged);
 
-	/**
-	 * Add linux <a
-	 * href="http://man7.org/linux/man-pages/man7/capabilities.7.html">kernel
-	 * capability</a> to the container. For example: adding {@link Capability#MKNOD}
-	 * allows the container to create special files using the 'mknod' command.
-	 */
 	@Deprecated
-	public StartContainerCmd withCapAdd(Capability... capAdd);
+	public StartContainerCmd withPublishAllPorts(Boolean publishAllPorts);
 
 	/**
-	 * Drop linux <a
-	 * href="http://man7.org/linux/man-pages/man7/capabilities.7.html">kernel
-	 * capability</a> from the container. For example: dropping {@link Capability#CHOWN}
-	 * prevents the container from changing the owner of any files.
+	 * Set custom {@link RestartPolicy} for the container. Defaults to
+	 * {@link RestartPolicy#noRestart()}
 	 */
 	@Deprecated
-	public StartContainerCmd withCapDrop(Capability... capDrop);
-
-	/**
-	 * @throws NotFoundException
-	 *             No such container
-	 * @throws NotModifiedException
-	 *             Container already started
-	 */
-	@Override
-	public Void exec() throws NotFoundException, NotModifiedException;
+	public StartContainerCmd withRestartPolicy(RestartPolicy restartPolicy);
 
-	public static interface Exec extends DockerCmdExec<StartContainerCmd, Void> {
-	}
+	@Deprecated
+	public StartContainerCmd withVolumesFrom(String volumesFrom);
 
 }
diff --git a/src/main/java/com/github/dockerjava/api/model/HostConfig.java b/src/main/java/com/github/dockerjava/api/model/HostConfig.java
index c72d078b..18fd3407 100644
--- a/src/main/java/com/github/dockerjava/api/model/HostConfig.java
+++ b/src/main/java/com/github/dockerjava/api/model/HostConfig.java
@@ -1,7 +1,10 @@
 package com.github.dockerjava.api.model;
 
+import java.util.Map;
+
 import org.apache.commons.lang.builder.ToStringBuilder;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import com.fasterxml.jackson.annotation.JsonProperty;
 
@@ -9,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
 public class HostConfig {
 
 	@JsonProperty("Binds")
-	private String[] binds;
+	private Binds binds;
 
 	@JsonProperty("Links")
 	private Links links;
@@ -59,12 +62,12 @@ public class HostConfig {
 	public HostConfig() {
 	}
 
-	public HostConfig(String[] binds, Links links, LxcConf[] lxcConf, Ports portBindings, boolean publishAllPorts,
+	public HostConfig(Bind[] binds, Link[] links, LxcConf[] lxcConf, Ports portBindings, boolean publishAllPorts,
 			boolean privileged, String[] dns, String[] dnsSearch, VolumesFrom[] volumesFrom, String containerIDFile,
 			Capability[] capAdd, Capability[] capDrop, RestartPolicy restartPolicy, String networkMode, Device[] devices,
             String[] extraHosts) {
-		this.binds = binds;
-		this.links = links;
+		this.binds = new Binds(binds);
+		this.links = new Links(links);
 		this.lxcConf = lxcConf;
 		this.portBindings = portBindings;
 		this.publishAllPorts = publishAllPorts;
@@ -81,14 +84,16 @@ public class HostConfig {
 		this.extraHosts = extraHosts;
 	}
 
-	public String[] getBinds() {
-		return binds;
+
+	@JsonIgnore
+	public Bind[] getBinds() {
+		return (binds == null) ? new Bind[0] : binds.getBinds();
 	}
 
 	public LxcConf[] getLxcConf() {
 		return lxcConf;
 	}
-
+	
 	public Ports getPortBindings() {
 		return portBindings;
 	}
@@ -117,8 +122,9 @@ public class HostConfig {
 		return dnsSearch;
 	}
 
-	public Links getLinks() {
-		return links;
+	@JsonIgnore
+	public Link[] getLinks() {
+		return (links == null) ? new Link[0] : links.getLinks();
 	}
 
 	public String getNetworkMode() {
@@ -145,12 +151,14 @@ public class HostConfig {
 		return capDrop;
 	}
 
-	public void setBinds(String[] binds) {
-		this.binds = binds;
+	@JsonIgnore
+	public void setBinds(Bind... binds) {
+		this.binds = new Binds(binds);
 	}
 
-	public void setLinks(Links links) {
-		this.links = links;
+	@JsonIgnore
+	public void setLinks(Link... links) {
+		this.links = new Links(links);
 	}
 
 	public void setLxcConf(LxcConf[] lxcConf) {
diff --git a/src/main/java/com/github/dockerjava/api/model/Links.java b/src/main/java/com/github/dockerjava/api/model/Links.java
index 888c0aa2..9bbef25d 100644
--- a/src/main/java/com/github/dockerjava/api/model/Links.java
+++ b/src/main/java/com/github/dockerjava/api/model/Links.java
@@ -31,10 +31,6 @@ public class Links
 		this.links = links;
 	}
 
-	public Links(final List<Link> links) {
-		this.links = links.toArray(new Link[links.size()]);
-	}
-
 	public Link[] getLinks()
 	{
 		return links;
diff --git a/src/main/java/com/github/dockerjava/api/model/Ports.java b/src/main/java/com/github/dockerjava/api/model/Ports.java
index e0f3c080..d7c8a324 100644
--- a/src/main/java/com/github/dockerjava/api/model/Ports.java
+++ b/src/main/java/com/github/dockerjava/api/model/Ports.java
@@ -3,8 +3,10 @@ package com.github.dockerjava.api.model;
 import static org.apache.commons.lang.StringUtils.isEmpty;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
@@ -59,6 +61,10 @@ public class Ports {
     public Ports(ExposedPort exposedPort, Binding host) {
     	bind(exposedPort, host);
     }
+    
+    public Ports(PortBinding... portBindings) {
+    	add(portBindings);
+    }
 
     /**
      * Adds a new {@link PortBinding} for the specified {@link ExposedPort} and
@@ -97,6 +103,16 @@ public class Ports {
     public Map<ExposedPort, Binding[]> getBindings(){
         return ports;
     }
+    
+//    public PortBinding[] getBindingsAsArray() {
+//    	List<PortBinding> bindings = new ArrayList<>();
+//    	for(Map.Entry<ExposedPort, Ports.Binding[]> entry: ports.entrySet()) {
+//    		for(Ports.Binding binding : entry.getValue()) {
+//    			bindings.add(new PortBinding(binding, entry.getKey()));
+//    		}
+//    	}
+//    	return bindings.toArray(new PortBinding[bindings.size()]);
+//    }
 
     /**
      * Creates a {@link Binding} for the given IP address and port number.
diff --git a/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java b/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java
index ac32960a..5afd0dbb 100644
--- a/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java
+++ b/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java
@@ -10,370 +10,546 @@ import com.github.dockerjava.api.ConflictException;
 import com.github.dockerjava.api.NotFoundException;
 import com.github.dockerjava.api.command.CreateContainerCmd;
 import com.github.dockerjava.api.command.CreateContainerResponse;
+import com.github.dockerjava.api.model.Bind;
 import com.github.dockerjava.api.model.Capability;
+import com.github.dockerjava.api.model.Device;
 import com.github.dockerjava.api.model.ExposedPort;
 import com.github.dockerjava.api.model.ExposedPorts;
 import com.github.dockerjava.api.model.HostConfig;
+import com.github.dockerjava.api.model.Link;
+import com.github.dockerjava.api.model.LxcConf;
+import com.github.dockerjava.api.model.PortBinding;
+import com.github.dockerjava.api.model.Ports;
+import com.github.dockerjava.api.model.RestartPolicy;
 import com.github.dockerjava.api.model.Volume;
 import com.github.dockerjava.api.model.VolumesFrom;
 import com.github.dockerjava.api.model.Volumes;
 
 /**
- *
+ * 
  * Creates a new container.
- *
+ * 
  */
-public class CreateContainerCmdImpl extends AbstrDockerCmd<CreateContainerCmd, CreateContainerResponse> implements CreateContainerCmd  {
+public class CreateContainerCmdImpl extends
+		AbstrDockerCmd<CreateContainerCmd, CreateContainerResponse> implements
+		CreateContainerCmd {
 
 	private String name;
-	
-	@JsonProperty("Hostname")     private String    hostName = "";
-    @JsonProperty("User")         private String    user = "";
-    @JsonProperty("Memory")       private long      memoryLimit = 0;
-    @JsonProperty("MemorySwap")   private long      memorySwap = 0;
-    @JsonProperty("CpuShares")    private int       cpuShares = 0;
-    @JsonProperty("Cpuset")       private String    cpuset;
-    @JsonProperty("AttachStdin")  private boolean   attachStdin = false;
-    @JsonProperty("AttachStdout") private boolean   attachStdout = false;
-    @JsonProperty("AttachStderr") private boolean   attachStderr = false;
-    @JsonProperty("PortSpecs")    private String[]  portSpecs;
-    @JsonProperty("Tty")          private boolean   tty = false;
-    @JsonProperty("OpenStdin")    private boolean   stdinOpen = false;
-    @JsonProperty("StdinOnce")    private boolean   stdInOnce = false;
-    @JsonProperty("Env")          private String[]  env;
-    @JsonProperty("Cmd")          private String[]  cmd;
-    @JsonProperty("Entrypoint")   private String[]  entrypoint;
-    @JsonProperty("Image")        private String    image;
-    @JsonProperty("Volumes")      private Volumes volumes = new Volumes();
-    @JsonProperty("WorkingDir")   private String workingDir = "";
-    @JsonProperty("DisableNetwork") private boolean disableNetwork = false;
-    @JsonProperty("ExposedPorts")   private ExposedPorts exposedPorts = new ExposedPorts();
-    @JsonProperty("HostConfig")   private HostConfig hostConfig = new HostConfig();
-	
+
+	@JsonProperty("Hostname")
+	private String hostName = "";
+	@JsonProperty("User")
+	private String user = "";
+	@JsonProperty("Memory")
+	private long memoryLimit = 0;
+	@JsonProperty("MemorySwap")
+	private long memorySwap = 0;
+	@JsonProperty("CpuShares")
+	private int cpuShares = 0;
+	@JsonProperty("Cpuset")
+	private String cpuset;
+	@JsonProperty("AttachStdin")
+	private boolean attachStdin = false;
+	@JsonProperty("AttachStdout")
+	private boolean attachStdout = false;
+	@JsonProperty("AttachStderr")
+	private boolean attachStderr = false;
+	@JsonProperty("PortSpecs")
+	private String[] portSpecs;
+	@JsonProperty("Tty")
+	private boolean tty = false;
+	@JsonProperty("OpenStdin")
+	private boolean stdinOpen = false;
+	@JsonProperty("StdinOnce")
+	private boolean stdInOnce = false;
+	@JsonProperty("Env")
+	private String[] env;
+	@JsonProperty("Cmd")
+	private String[] cmd;
+	@JsonProperty("Entrypoint")
+	private String[] entrypoint;
+	@JsonProperty("Image")
+	private String image;
+	@JsonProperty("Volumes")
+	private Volumes volumes = new Volumes();
+	@JsonProperty("WorkingDir")
+	private String workingDir = "";
+	@JsonProperty("DisableNetwork")
+	private boolean disableNetwork = false;
+	@JsonProperty("ExposedPorts")
+	private ExposedPorts exposedPorts = new ExposedPorts();
+	@JsonProperty("HostConfig")
+	private HostConfig hostConfig = new HostConfig();
+
 	public CreateContainerCmdImpl(CreateContainerCmd.Exec exec, String image) {
 		super(exec);
 		checkNotNull(image, "image was not specified");
 		withImage(image);
 	}
 
+	/**
+	 * @throws NotFoundException
+	 *             No such container
+	 * @throws ConflictException
+	 *             Named container already exists
+	 */
 	@Override
-	public CreateContainerCmdImpl withName(String name) {
-		checkNotNull(name, "name was not specified");
-        this.name = name;
-        return this;
-    }
+	public CreateContainerResponse exec() throws NotFoundException,
+			ConflictException {
+		return super.exec();
+	}
 
-    @Override
-	public String getName() {
-        return name;
-    }
+	@Override
+	@JsonIgnore
+	public Bind[] getBinds() {
+		return hostConfig.getBinds();
+	}
 
-    @Override
-	public CreateContainerCmdImpl withExposedPorts(ExposedPort... exposedPorts) {
-        this.exposedPorts = new ExposedPorts(exposedPorts);
-        return this;
-    }
+	@Override
+	public Capability[] getCapAdd() {
+		return hostConfig.getCapAdd();
+	}
+
+	@Override
+	public Capability[] getCapDrop() {
+		return hostConfig.getCapDrop();
+	}
+
+	@Override
+	public String[] getCmd() {
+		return cmd;
+	}
+
+	@Override
+	public String getCpuset() {
+		return cpuset;
+	}
+
+	@Override
+	public int getCpuShares() {
+		return cpuShares;
+	}
 
-    @Override
+	@Override
 	@JsonIgnore
-    public ExposedPort[] getExposedPorts() {
-        return exposedPorts.getExposedPorts();
-    }
+	public Device[] getDevices() {
+		return hostConfig.getDevices();
+	}
 
+	@Override
+	@JsonIgnore
+	public String[] getDns() {
+		return hostConfig.getDns();
+	}
 
-    @Override
-	public boolean isDisableNetwork() {
-        return disableNetwork;
-    }
+	@Override
+	@JsonIgnore
+	public String[] getDnsSearch() {
+		return hostConfig.getDnsSearch();
+	}
 
-    @Override
-	public String getWorkingDir() { 
-    	return workingDir;
-    }
+	@Override
+	public String[] getEntrypoint() {
+		return entrypoint;
+	}
 
-    @Override
-	public CreateContainerCmdImpl withWorkingDir(String workingDir) {
-        this.workingDir = workingDir;
-        return this;
-    }
+	@Override
+	public String[] getEnv() {
+		return env;
+	}
+
+	@Override
+	@JsonIgnore
+	public ExposedPort[] getExposedPorts() {
+		return exposedPorts.getExposedPorts();
+	}
 
+	@Override
+	@JsonIgnore
+	public String[] getExtraHosts() {
+		return hostConfig.getExtraHosts();
+	}
+
+	@Override
+	public HostConfig getHostConfig() {
+		return hostConfig;
+	}
 
-    @Override
+	@Override
 	public String getHostName() {
-        return hostName;
-    }
+		return hostName;
+	}
 
-    @Override
-	public CreateContainerCmdImpl withDisableNetwork(boolean disableNetwork) {
-        this.disableNetwork = disableNetwork;
-        return this;
-    }
+	@Override
+	public String getImage() {
+		return image;
+	}
 
-    @Override
-	public CreateContainerCmdImpl withHostName(String hostName) {
-        this.hostName = hostName;
-        return this;
-    }
+	@Override
+	@JsonIgnore
+	public Link[] getLinks() {
+		return hostConfig.getLinks();
+	}
+
+	@Override
+	@JsonIgnore
+	public LxcConf[] getLxcConf() {
+		return hostConfig.getLxcConf();
+	}
+
+	@Override
+	public long getMemoryLimit() {
+		return memoryLimit;
+	}
+
+	@Override
+	public long getMemorySwap() {
+		return memorySwap;
+	}
+
+	@Override
+	public String getName() {
+		return name;
+	}
 
-    @Override
+	@Override
+	@JsonIgnore
+	public String getNetworkMode() {
+		return hostConfig.getNetworkMode();
+	}
+
+	@Override
+	@JsonIgnore
+	public Ports getPortBindings() {
+		return hostConfig.getPortBindings();
+	}
+
+	@Override
 	public String[] getPortSpecs() {
-        return portSpecs;
-    }
+		return portSpecs;
+	}
 
-    @Override
-	public CreateContainerCmdImpl withPortSpecs(String... portSpecs) {
-        this.portSpecs = portSpecs;
-        return this;
-    }
+	@Override
+	@JsonIgnore
+	public RestartPolicy getRestartPolicy() {
+		return hostConfig.getRestartPolicy();
+	}
 
-    @Override
+	@Override
 	public String getUser() {
-        return user;
-    }
+		return user;
+	}
 
-    @Override
-	public CreateContainerCmdImpl withUser(String user) {
-        this.user = user;
-        return this;
-    }
+	@Override
+	@JsonIgnore
+	public Volume[] getVolumes() {
+		return volumes.getVolumes();
+	}
 
-    @Override
-	public boolean isTty() {
-        return tty;
-    }
+	@Override
+	@JsonIgnore
+	public VolumesFrom[] getVolumesFrom() {
+		return hostConfig.getVolumesFrom();
+	}
 
-    @Override
-	public CreateContainerCmdImpl withTty(boolean tty) {
-        this.tty = tty;
-        return this;
-    }
+	@Override
+	public String getWorkingDir() {
+		return workingDir;
+	}
 
-    @Override
-	public boolean isStdinOpen() {
-        return stdinOpen;
-    }
+	@Override
+	public boolean isAttachStderr() {
+		return attachStderr;
+	}
 
-    @Override
-	public CreateContainerCmdImpl withStdinOpen(boolean stdinOpen) {
-        this.stdinOpen = stdinOpen;
-        return this;
-    }
+	@Override
+	public boolean isAttachStdin() {
+		return attachStdin;
+	}
 
-    @Override
+	@Override
+	public boolean isAttachStdout() {
+		return attachStdout;
+	}
+
+	@Override
+	public boolean isDisableNetwork() {
+		return disableNetwork;
+	}
+
+	@Override
+	@JsonIgnore
+	public Boolean isPrivileged() {
+		return hostConfig.isPrivileged();
+	}
+
+	@Override
+	@JsonIgnore
+	public Boolean isPublishAllPorts() {
+		return hostConfig.isPublishAllPorts();
+	}
+
+	@Override
 	public boolean isStdInOnce() {
-        return stdInOnce;
-    }
+		return stdInOnce;
+	}
 
-    @Override
-	public CreateContainerCmdImpl withStdInOnce(boolean stdInOnce) {
-        this.stdInOnce = stdInOnce;
-        return this;
-    }
+	@Override
+	public boolean isStdinOpen() {
+		return stdinOpen;
+	}
 
-    @Override
-	public long getMemoryLimit() {
-        return memoryLimit;
-    }
+	@Override
+	public boolean isTty() {
+		return tty;
+	}
 
-    @Override
-	public CreateContainerCmdImpl withMemoryLimit(long memoryLimit) {
-        this.memoryLimit = memoryLimit;
-        return this;
-    }
+	@Override
+	public String toString() {
+		return new ToStringBuilder(this).append("create container ")
+				.append(name != null ? "name=" + name + " " : "").append(this)
+				.toString();
+	}
 
-    @Override
-	public long getMemorySwap() {
-        return memorySwap;
-    }
+	@Override
+	public CreateContainerCmdImpl withAttachStderr(boolean attachStderr) {
+		this.attachStderr = attachStderr;
+		return this;
+	}
 
-    @Override
-	public CreateContainerCmdImpl withMemorySwap(long memorySwap) {
-        this.memorySwap = memorySwap;
-        return this;
-    }
+	@Override
+	public CreateContainerCmdImpl withAttachStdin(boolean attachStdin) {
+		this.attachStdin = attachStdin;
+		return this;
+	}
 
-    @Override
-	public int getCpuShares() {
-        return cpuShares;
-    }
+	@Override
+	public CreateContainerCmdImpl withAttachStdout(boolean attachStdout) {
+		this.attachStdout = attachStdout;
+		return this;
+	}
 
-    @Override
-	public CreateContainerCmdImpl withCpuShares(int cpuShares) {
-        this.cpuShares = cpuShares;
-        return this;
-    }
+	@Override
+	public CreateContainerCmd withBinds(Bind... binds) {
+		hostConfig.setBinds(binds);
+		return this;
+	}
 
-    @Override
-	public String getCpuset() {
-        return cpuset;
-    }
+	@Override
+	public CreateContainerCmd withCapAdd(Capability... capAdd) {
+		hostConfig.setCapAdd(capAdd);
+		return this;
+	}
 
-    @Override
-	public CreateContainerCmdImpl withCpuset(String cpuset) {
-        this.cpuset = cpuset;
-        return this;
-    }
+	@Override
+	public CreateContainerCmd withCapDrop(Capability... capDrop) {
+		hostConfig.setCapDrop(capDrop);
+		return this;
+	}
 
-    @Override
-	public boolean isAttachStdin() {
-        return attachStdin;
-    }
+	@Override
+	public CreateContainerCmdImpl withCmd(String... cmd) {
+		this.cmd = cmd;
+		return this;
+	}
 
-    @Override
-	public CreateContainerCmdImpl withAttachStdin(boolean attachStdin) {
-        this.attachStdin = attachStdin;
-        return this;
-    }
+	@Override
+	public CreateContainerCmdImpl withCpuset(String cpuset) {
+		this.cpuset = cpuset;
+		return this;
+	}
 
-    @Override
-	public boolean isAttachStdout() {
-        return attachStdout;
-    }
+	@Override
+	public CreateContainerCmdImpl withCpuShares(int cpuShares) {
+		this.cpuShares = cpuShares;
+		return this;
+	}
 
-    @Override
-	public CreateContainerCmdImpl withAttachStdout(boolean attachStdout) {
-        this.attachStdout = attachStdout;
-        return this;
-    }
+	@Override
+	public CreateContainerCmd withDevices(Device... devices) {
+		this.hostConfig.setDevices(devices);
+		return this;
+	}
 
-    @Override
-	public boolean isAttachStderr() {
-        return attachStderr;
-    }
+	@Override
+	public CreateContainerCmdImpl withDisableNetwork(boolean disableNetwork) {
+		this.disableNetwork = disableNetwork;
+		return this;
+	}
 
-    @Override
-	public CreateContainerCmdImpl withAttachStderr(boolean attachStderr) {
-        this.attachStderr = attachStderr;
-        return this;
-    }
+	@Override
+	public CreateContainerCmdImpl withDns(String... dns) {
+		this.hostConfig.setDns(dns);
+		return this;
+	}
 
-    @Override
-	public String[] getEnv() {
-        return env;
-    }
+	@Override
+	public CreateContainerCmd withDnsSearch(String... dnsSearch) {
+		this.hostConfig.setDnsSearch(dnsSearch);
+		return this;
+	}
 
-    @Override
+	@Override
+	public CreateContainerCmdImpl withEntrypoint(String... entrypoint) {
+		this.entrypoint = entrypoint;
+		return this;
+	}
+
+	@Override
 	public CreateContainerCmdImpl withEnv(String... env) {
-        this.env = env;
-        return this;
-    }
+		this.env = env;
+		return this;
+	}
 
-    @Override
-	public String[] getCmd() {
-        return cmd;
-    }
+	@Override
+	public CreateContainerCmdImpl withExposedPorts(ExposedPort... exposedPorts) {
+		this.exposedPorts = new ExposedPorts(exposedPorts);
+		return this;
+	}
 
-    @Override
-	public CreateContainerCmdImpl withCmd(String... cmd) {
-        this.cmd = cmd;
-        return this;
-    }
-    
-    @Override
-    public String[] getEntrypoint() {
-    	return entrypoint;
-    }
-    
-    @Override
-	public CreateContainerCmdImpl withEntrypoint(String... entrypoint) {
-        this.entrypoint = entrypoint;
-        return this;
-    }
-
-    @Override
-    public String[] getDns() {
-        return hostConfig.getDns();
-    }
-
-    @Override
-    public CreateContainerCmdImpl withDns(String... dns) {
-        hostConfig.setDns(dns);
-        return this;
-    }
-
-    @Override
-	public String getImage() {
-        return image;
-    }
+	@Override
+	public CreateContainerCmd withExtraHosts(String... extraHosts) {
+		this.hostConfig.setExtraHosts(extraHosts);
+		return this;
+	}
+
+	@Override
+	public CreateContainerCmd withHostConfig(HostConfig hostConfig) {
+		checkNotNull(hostConfig, "no host config was specified");
+		this.hostConfig = hostConfig;
+		return this;
+	}
+
+	@Override
+	public CreateContainerCmdImpl withHostName(String hostName) {
+		this.hostName = hostName;
+		return this;
+	}
 
-    @Override
+	@Override
 	public CreateContainerCmdImpl withImage(String image) {
-        this.image = image;
-        return this;
-    }
+		this.image = image;
+		return this;
+	}
 
-    @Override
-	@JsonIgnore
-    public Volume[] getVolumes() {
-        return volumes.getVolumes();
-    }
+	@Override
+	public CreateContainerCmdImpl withLinks(Link... links) {
+		checkNotNull(links, "links was not specified");
+		this.hostConfig.setLinks(links);
+		return this;
+	}
 
-    @Override
-	public CreateContainerCmdImpl withVolumes(Volume... volumes) {
-        this.volumes = new Volumes(volumes);
-        return this;
-    }
+	@Override
+	public CreateContainerCmd withLxcConf(LxcConf... lxcConf) {
+		checkNotNull(lxcConf, "lxcConf was not specified");
+		this.hostConfig.setLxcConf(lxcConf);
+		return this;
+	}
 
-    @Override
-	public VolumesFrom[] getVolumesFrom() {
-        return hostConfig.getVolumesFrom();
-    }
+	@Override
+	public CreateContainerCmdImpl withMemoryLimit(long memoryLimit) {
+		this.memoryLimit = memoryLimit;
+		return this;
+	}
+
+	@Override
+	public CreateContainerCmdImpl withMemorySwap(long memorySwap) {
+		this.memorySwap = memorySwap;
+		return this;
+	}
+
+	@Override
+	public CreateContainerCmdImpl withName(String name) {
+		checkNotNull(name, "name was not specified");
+		this.name = name;
+		return this;
+	}
+
+	@Override
+	public CreateContainerCmd withNetworkMode(String networkMode) {
+		checkNotNull(networkMode, "networkMode was not specified");
+		this.hostConfig.setNetworkMode(networkMode);
+		return this;
+	}
+
+	@Override
+	public CreateContainerCmd withPortBindings(PortBinding... portBindings) {
+		checkNotNull(portBindings, "portBindings was not specified");
+		this.hostConfig.setPortBindings(new Ports(portBindings));
+		return this;
+	}
+
+	@Override
+	public CreateContainerCmd withPortBindings(Ports portBindings) {
+		checkNotNull(portBindings, "portBindings was not specified");
+		this.hostConfig.setPortBindings(portBindings);
+		return this;
+	}
+
+	@Override
+	public CreateContainerCmdImpl withPortSpecs(String... portSpecs) {
+		this.portSpecs = portSpecs;
+		return this;
+	}
+
+	@Override
+	public CreateContainerCmd withPrivileged(boolean privileged) {
+		this.hostConfig.setPrivileged(privileged);
+		return this;
+	}
+
+	@Override
+	public CreateContainerCmd withPublishAllPorts(boolean publishAllPorts) {
+		this.hostConfig.setPublishAllPorts(publishAllPorts);
+		return this;
+	}
+	
+	@Override
+	public CreateContainerCmd withRestartPolicy(RestartPolicy restartPolicy) {
+		this.hostConfig.setRestartPolicy(restartPolicy);
+		return this;
+	}
+
+	@Override
+	public CreateContainerCmdImpl withStdInOnce(boolean stdInOnce) {
+		this.stdInOnce = stdInOnce;
+		return this;
+	}
 
-    @Override
+	@Override
+	public CreateContainerCmdImpl withStdinOpen(boolean stdinOpen) {
+		this.stdinOpen = stdinOpen;
+		return this;
+	}
+
+	@Override
+	public CreateContainerCmdImpl withTty(boolean tty) {
+		this.tty = tty;
+		return this;
+	}
+
+	@Override
+	public CreateContainerCmdImpl withUser(String user) {
+		this.user = user;
+		return this;
+	}
+
+	@Override
+	public CreateContainerCmdImpl withVolumes(Volume... volumes) {
+		this.volumes = new Volumes(volumes);
+		return this;
+	}
+
+	@Override
 	public CreateContainerCmdImpl withVolumesFrom(VolumesFrom... volumesFrom) {
-        this.hostConfig.setVolumesFrom(volumesFrom);
-        return this;
-    }
-
-    @Override
-    public HostConfig getHostConfig() {
-    	return hostConfig;
-    }
-    
-    @Override
-    public CreateContainerCmd withHostConfig(HostConfig hostConfig) {
-    	checkNotNull(hostConfig, "no host config was specified");
-    	this.hostConfig = hostConfig;
-    	return this;
-    }
-    
-    @Override
-    public Capability[] getCapAdd() {
-        return hostConfig.getCapAdd();
-    }
-
-    @Override
-    public CreateContainerCmd withCapAdd(Capability... capAdd) {
-        hostConfig.setCapAdd(capAdd);
-        return this;
-    }
-
-    @Override
-    public Capability[] getCapDrop() {
-        return hostConfig.getCapDrop();
-    }
-
-    @Override
-    public CreateContainerCmd withCapDrop(Capability... capDrop) {
-        hostConfig.setCapDrop(capDrop);
-        return this;
-    }
-
-	@Override
-    public String toString() {
-        return new ToStringBuilder(this).append("create container ")
-            .append(name != null ? "name=" + name + " " : "")
-            .append(this)
-            .toString();
-    }
-    
-    /**
-     * @throws NotFoundException No such container
-     * @throws ConflictException Named container already exists
-     */
-	@Override
-    public CreateContainerResponse exec() throws NotFoundException, ConflictException {
-    	return super.exec();
-    }
-
-}    
+		this.hostConfig.setVolumesFrom(volumesFrom);
+		return this;
+	}
+
+	@Override
+	public CreateContainerCmdImpl withWorkingDir(String workingDir) {
+		this.workingDir = workingDir;
+		return this;
+	}
+
+}


Test patch:
diff --git a/src/test/java/com/github/dockerjava/core/command/CreateContainerCmdImplTest.java b/src/test/java/com/github/dockerjava/core/command/CreateContainerCmdImplTest.java
index ba05b268..f652c570 100644
--- a/src/test/java/com/github/dockerjava/core/command/CreateContainerCmdImplTest.java
+++ b/src/test/java/com/github/dockerjava/core/command/CreateContainerCmdImplTest.java
@@ -1,6 +1,7 @@
 package com.github.dockerjava.core.command;
 
-import static com.github.dockerjava.api.model.Capability.*;
+import static com.github.dockerjava.api.model.Capability.MKNOD;
+import static com.github.dockerjava.api.model.Capability.NET_ADMIN;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.containsInAnyOrder;
@@ -10,6 +11,8 @@ import static org.hamcrest.Matchers.hasItemInArray;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.isEmptyString;
 import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.startsWith;
 
 import java.lang.reflect.Method;
 import java.security.SecureRandom;
@@ -28,9 +31,12 @@ import com.github.dockerjava.api.DockerException;
 import com.github.dockerjava.api.command.CreateContainerResponse;
 import com.github.dockerjava.api.command.InspectContainerResponse;
 import com.github.dockerjava.api.model.Bind;
+import com.github.dockerjava.api.model.Device;
+import com.github.dockerjava.api.model.ExposedPort;
 import com.github.dockerjava.api.model.HostConfig;
 import com.github.dockerjava.api.model.Link;
-import com.github.dockerjava.api.model.Links;
+import com.github.dockerjava.api.model.Ports;
+import com.github.dockerjava.api.model.RestartPolicy;
 import com.github.dockerjava.api.model.Volume;
 import com.github.dockerjava.api.model.VolumesFrom;
 import com.github.dockerjava.client.AbstractDockerClientTest;
@@ -99,7 +105,7 @@ public class CreateContainerCmdImplTest extends AbstractDockerClientTest {
 		assertThat(inspectContainerResponse.getConfig().getVolumes().keySet(),
 				contains("/var/log"));
 	}
-
+	
 	@Test
 	public void createContainerWithVolumesFrom() throws DockerException {
 
@@ -111,11 +117,12 @@ public class CreateContainerCmdImplTest extends AbstractDockerClientTest {
 		// create a running container with bind mounts
 		CreateContainerResponse container1 = dockerClient
 				.createContainerCmd("busybox").withCmd("sleep", "9999")
-				.withName(container1Name).exec();
+				.withName(container1Name)
+				.withBinds(new Bind("/src/webapp1", volume1), new Bind("/src/webapp2", volume2))
+				.exec();
 		LOG.info("Created container1 {}", container1.toString());
 
-		dockerClient.startContainerCmd(container1.getId()).withBinds(
-				new Bind("/src/webapp1", volume1), new Bind("/src/webapp2", volume2)).exec();
+		dockerClient.startContainerCmd(container1.getId()).exec();
 		LOG.info("Started container1 {}", container1.toString());
 
 		InspectContainerResponse inspectContainerResponse1 = dockerClient.inspectContainerCmd(
@@ -238,7 +245,7 @@ public class CreateContainerCmdImplTest extends AbstractDockerClientTest {
 		assertThat(inspectContainerResponse1.getState().isRunning(), is(true));
 
 		HostConfig hostConfig = new HostConfig();
-		hostConfig.setLinks(new Links(new Link("container1", "container1Link")));
+		hostConfig.setLinks(new Link("container1", "container1Link"));
 		CreateContainerResponse container2 = dockerClient
 				.createContainerCmd("busybox").withName("container2").withHostConfig(hostConfig)
 				.withCmd("env").exec();
@@ -247,7 +254,7 @@ public class CreateContainerCmdImplTest extends AbstractDockerClientTest {
 
 		InspectContainerResponse inspectContainerResponse2 = dockerClient
 				.inspectContainerCmd(container2.getId()).exec();
-		assertThat(inspectContainerResponse2.getHostConfig().getLinks().getLinks(), equalTo(new Link[] {new Link("container1","container1Link")}));
+		assertThat(inspectContainerResponse2.getHostConfig().getLinks(), equalTo(new Link[] {new Link("container1","container1Link")}));
 	}
 
 	@Test
@@ -333,5 +340,174 @@ public class CreateContainerCmdImplTest extends AbstractDockerClientTest {
 		assertThat(Arrays.asList(inspectContainerResponse.getHostConfig().getExtraHosts()),
 				containsInAnyOrder("dockerhost:127.0.0.1", "otherhost:10.0.0.1"));
 	}
+	
+	@Test
+	public void createContainerWithDevices() throws DockerException {
+
+		CreateContainerResponse container = dockerClient
+				.createContainerCmd("busybox").withCmd("sleep", "9999")
+				.withDevices(new Device("rwm", "/dev/nulo", "/dev/zero"))
+				.exec();
+
+		LOG.info("Created container {}", container.toString());
+
+		assertThat(container.getId(), not(isEmptyString()));
+
+		InspectContainerResponse inspectContainerResponse = dockerClient
+				.inspectContainerCmd(container.getId()).exec();
+
+		assertThat(Arrays.asList(inspectContainerResponse.getHostConfig()
+				.getDevices()), contains(new Device("rwm", "/dev/nulo",
+				"/dev/zero")));
+	}
+	
+	@Test
+	public void createContainerWithPortBindings() throws DockerException {
+
+		ExposedPort tcp22 = ExposedPort.tcp(22);
+		ExposedPort tcp23 = ExposedPort.tcp(23);
+		
+		Ports portBindings = new Ports();
+		portBindings.bind(tcp22, Ports.Binding(11022));
+		portBindings.bind(tcp23, Ports.Binding(11023));
+		portBindings.bind(tcp23, Ports.Binding(11024));
+
+		CreateContainerResponse container = dockerClient
+				.createContainerCmd("busybox").withCmd("true")
+				.withExposedPorts(tcp22, tcp23)
+				.withPortBindings(portBindings)
+				.exec();
+
+		LOG.info("Created container {}", container.toString());
+
+		assertThat(container.getId(), not(isEmptyString()));
+
+		InspectContainerResponse inspectContainerResponse = dockerClient
+				.inspectContainerCmd(container.getId()).exec();
+
+		assertThat(Arrays.asList(inspectContainerResponse.getConfig()
+				.getExposedPorts()), contains(tcp22, tcp23));
+
+		assertThat(inspectContainerResponse.getHostConfig().getPortBindings()
+				.getBindings().get(tcp22)[0], is(equalTo(Ports.Binding(11022))));
+
+		assertThat(inspectContainerResponse.getHostConfig().getPortBindings()
+				.getBindings().get(tcp23)[0], is(equalTo(Ports.Binding(11023))));
+
+		assertThat(inspectContainerResponse.getHostConfig().getPortBindings()
+				.getBindings().get(tcp23)[1], is(equalTo(Ports.Binding(11024))));
+
+	}
+	
+	@Test
+	public void createContainerWithLinking() throws DockerException {
+
+		CreateContainerResponse container1 = dockerClient
+				.createContainerCmd("busybox")
+				.withCmd("sleep", "9999")
+				.withName("container1").exec();
+
+		LOG.info("Created container1 {}", container1.toString());
+		assertThat(container1.getId(), not(isEmptyString()));
+
+		dockerClient.startContainerCmd(container1.getId()).exec();
+
+		InspectContainerResponse inspectContainerResponse1 = dockerClient
+				.inspectContainerCmd(container1.getId()).exec();
+		LOG.info("Container1 Inspect: {}", inspectContainerResponse1.toString());
+
+		assertThat(inspectContainerResponse1.getConfig(), is(notNullValue()));
+		assertThat(inspectContainerResponse1.getId(), not(isEmptyString()));
+		assertThat(inspectContainerResponse1.getId(),
+				startsWith(container1.getId()));
+		assertThat(inspectContainerResponse1.getName(), equalTo("/container1"));
+		assertThat(inspectContainerResponse1.getImageId(), not(isEmptyString()));
+		assertThat(inspectContainerResponse1.getState(), is(notNullValue()));
+		assertThat(inspectContainerResponse1.getState().isRunning(), is(true));
+
+		if (!inspectContainerResponse1.getState().isRunning()) {
+			assertThat(inspectContainerResponse1.getState().getExitCode(),
+					is(equalTo(0)));
+		}
+
+		CreateContainerResponse container2 = dockerClient
+				.createContainerCmd("busybox").withCmd("sleep", "9999")
+				.withName("container2")
+				.withLinks(new Link("container1", "container1Link"))
+				.exec();
+
+		LOG.info("Created container2 {}", container2.toString());
+		assertThat(container2.getId(), not(isEmptyString()));
+		
+		InspectContainerResponse inspectContainerResponse2 = dockerClient
+				.inspectContainerCmd(container2.getId()).exec();
+		LOG.info("Container2 Inspect: {}", inspectContainerResponse2.toString());
+
+		assertThat(inspectContainerResponse2.getConfig(), is(notNullValue()));
+		assertThat(inspectContainerResponse2.getId(), not(isEmptyString()));
+		assertThat(inspectContainerResponse2.getHostConfig(),
+				is(notNullValue()));
+		assertThat(inspectContainerResponse2.getHostConfig().getLinks(),
+				is(notNullValue()));
+		assertThat(inspectContainerResponse2.getHostConfig().getLinks(), equalTo(new Link[] { new Link("container1",
+				"container1Link") }));
+		assertThat(inspectContainerResponse2.getId(),
+				startsWith(container2.getId()));
+		assertThat(inspectContainerResponse2.getName(), equalTo("/container2"));
+		assertThat(inspectContainerResponse2.getImageId(), not(isEmptyString()));
+		
+
+	}
+	
+	@Test
+	public void createContainerWithRestartPolicy() throws DockerException {
+
+		RestartPolicy restartPolicy = RestartPolicy.onFailureRestart(5);
+		
+		CreateContainerResponse container = dockerClient
+				.createContainerCmd("busybox")
+				.withCmd("sleep", "9999")
+				.withRestartPolicy(restartPolicy)
+				.exec();
+
+		LOG.info("Created container {}", container.toString());
+
+		assertThat(container.getId(), not(isEmptyString()));
+
+		InspectContainerResponse inspectContainerResponse = dockerClient
+				.inspectContainerCmd(container.getId()).exec();
+
+		assertThat(inspectContainerResponse.getHostConfig().getRestartPolicy(),
+				is(equalTo(restartPolicy)));
+	}
+
+	/**
+	 * This tests support for --net option for the docker run command:
+	 * --net="bridge" Set the Network mode for the container 'bridge': creates a
+	 * new network stack for the container on the docker bridge 'none': no
+	 * networking for this container 'container:': reuses another container
+	 * network stack 'host': use the host network stack inside the container.
+	 * Note: the host mode gives the container full access to local system
+	 * services such as D-bus and is therefore considered insecure.
+	 */
+	@Test
+	public void createContainerWithNetworkMode() throws DockerException {
 
+		CreateContainerResponse container = dockerClient
+				.createContainerCmd("busybox")
+				.withCmd("true")
+				.withNetworkMode("host")
+				.exec();
+
+		LOG.info("Created container {}", container.toString());
+
+		assertThat(container.getId(), not(isEmptyString()));
+
+		InspectContainerResponse inspectContainerResponse = dockerClient
+				.inspectContainerCmd(container.getId()).exec();
+
+		assertThat(inspectContainerResponse.getHostConfig().getNetworkMode(),
+				is(equalTo("host")));
+	}
+	
 }
diff --git a/src/test/java/com/github/dockerjava/core/command/StartContainerCmdImplTest.java b/src/test/java/com/github/dockerjava/core/command/StartContainerCmdImplTest.java
index 37d805aa..f7cbe20c 100644
--- a/src/test/java/com/github/dockerjava/core/command/StartContainerCmdImplTest.java
+++ b/src/test/java/com/github/dockerjava/core/command/StartContainerCmdImplTest.java
@@ -253,7 +253,7 @@ public class StartContainerCmdImplTest extends AbstractDockerClientTest {
 	}
 
 	@Test
-	public void startContainerWithLinking() throws DockerException {
+	public void startContainerWithLinkingDeprecated() throws DockerException {
 
 		CreateContainerResponse container1 = dockerClient
 				.createContainerCmd("busybox").withCmd("sleep", "9999")
@@ -302,8 +302,71 @@ public class StartContainerCmdImplTest extends AbstractDockerClientTest {
 				is(notNullValue()));
 		assertThat(inspectContainerResponse2.getHostConfig().getLinks(),
 				is(notNullValue()));
-		assertThat(inspectContainerResponse2.getHostConfig().getLinks()
-				.getLinks(), equalTo(new Link[] { new Link("container1",
+		assertThat(inspectContainerResponse2.getHostConfig().getLinks(), equalTo(new Link[] { new Link("container1",
+				"container1Link") }));
+		assertThat(inspectContainerResponse2.getId(),
+				startsWith(container2.getId()));
+		assertThat(inspectContainerResponse2.getName(), equalTo("/container2"));
+		assertThat(inspectContainerResponse2.getImageId(), not(isEmptyString()));
+		assertThat(inspectContainerResponse2.getState(), is(notNullValue()));
+		assertThat(inspectContainerResponse2.getState().isRunning(), is(true));
+
+	}
+	
+	
+	@Test
+	public void startContainerWithLinking() throws DockerException {
+
+		CreateContainerResponse container1 = dockerClient
+				.createContainerCmd("busybox").withCmd("sleep", "9999")
+				.withName("container1").exec();
+
+		LOG.info("Created container1 {}", container1.toString());
+		assertThat(container1.getId(), not(isEmptyString()));
+
+		dockerClient.startContainerCmd(container1.getId()).exec();
+
+		InspectContainerResponse inspectContainerResponse1 = dockerClient
+				.inspectContainerCmd(container1.getId()).exec();
+		LOG.info("Container1 Inspect: {}", inspectContainerResponse1.toString());
+
+		assertThat(inspectContainerResponse1.getConfig(), is(notNullValue()));
+		assertThat(inspectContainerResponse1.getId(), not(isEmptyString()));
+		assertThat(inspectContainerResponse1.getId(),
+				startsWith(container1.getId()));
+		assertThat(inspectContainerResponse1.getName(), equalTo("/container1"));
+		assertThat(inspectContainerResponse1.getImageId(), not(isEmptyString()));
+		assertThat(inspectContainerResponse1.getState(), is(notNullValue()));
+		assertThat(inspectContainerResponse1.getState().isRunning(), is(true));
+
+		if (!inspectContainerResponse1.getState().isRunning()) {
+			assertThat(inspectContainerResponse1.getState().getExitCode(),
+					is(equalTo(0)));
+		}
+
+		CreateContainerResponse container2 = dockerClient
+				.createContainerCmd("busybox").withCmd("sleep", "9999")
+				.withName("container2")
+				.withLinks(new Link("container1", "container1Link"))
+				.exec();
+
+		LOG.info("Created container2 {}", container2.toString());
+		assertThat(container2.getId(), not(isEmptyString()));
+
+		dockerClient.startContainerCmd(container2.getId())
+				.exec();
+
+		InspectContainerResponse inspectContainerResponse2 = dockerClient
+				.inspectContainerCmd(container2.getId()).exec();
+		LOG.info("Container2 Inspect: {}", inspectContainerResponse2.toString());
+
+		assertThat(inspectContainerResponse2.getConfig(), is(notNullValue()));
+		assertThat(inspectContainerResponse2.getId(), not(isEmptyString()));
+		assertThat(inspectContainerResponse2.getHostConfig(),
+				is(notNullValue()));
+		assertThat(inspectContainerResponse2.getHostConfig().getLinks(),
+				is(notNullValue()));
+		assertThat(inspectContainerResponse2.getHostConfig().getLinks(), equalTo(new Link[] { new Link("container1",
 				"container1Link") }));
 		assertThat(inspectContainerResponse2.getId(),
 				startsWith(container2.getId()));