diff --git a/api/handlers/container/create.go b/api/handlers/container/create.go index c59ae84..b422173 100644 --- a/api/handlers/container/create.go +++ b/api/handlers/container/create.go @@ -221,6 +221,7 @@ func (h *handler) create(w http.ResponseWriter, r *http.Request) { DNSResolvConfOptions: dnsOpt, // DNS options. DNSSearchDomains: req.HostConfig.DNSSearch, // Custom DNS search domains. PortMappings: portMappings, + AddHost: req.HostConfig.ExtraHosts, // Extra hosts. } ctx := namespaces.WithNamespace(r.Context(), h.Config.Namespace) diff --git a/api/handlers/container/create_test.go b/api/handlers/container/create_test.go index 4a90600..9c5475c 100644 --- a/api/handlers/container/create_test.go +++ b/api/handlers/container/create_test.go @@ -305,7 +305,8 @@ var _ = Describe("Container Create API ", func() { "HostConfig": { "DNS": ["8.8.8.8"], "DNSOptions": ["test-opt"], - "DNSSearch": ["test.com"] + "DNSSearch": ["test.com"], + "ExtraHosts": ["test-host:127.0.0.1"] } }`) req, _ := http.NewRequest(http.MethodPost, "/containers/create", bytes.NewReader(body)) @@ -315,6 +316,7 @@ var _ = Describe("Container Create API ", func() { netOpt.DNSServers = []string{"8.8.8.8"} netOpt.DNSResolvConfOptions = []string{"test-opt"} netOpt.DNSSearchDomains = []string{"test.com"} + netOpt.AddHost = []string{"test-host:127.0.0.1"} service.EXPECT().Create(gomock.Any(), "test-image", nil, equalTo(createOpt), equalTo(netOpt)).Return( cid, nil) diff --git a/api/types/container_types.go b/api/types/container_types.go index 7090117..800431e 100644 --- a/api/types/container_types.go +++ b/api/types/container_types.go @@ -76,7 +76,7 @@ type ContainerHostConfig struct { DNS []string `json:"Dns"` // List of DNS server to lookup DNSOptions []string `json:"DnsOptions"` // List of DNSOption to look for DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for - // TODO: ExtraHosts []string // List of extra hosts + ExtraHosts []string // List of extra hosts // TODO: GroupAdd []string // List of additional groups that the container process will run as // TODO: IpcMode IpcMode // IPC namespace to use for the container // TODO: Cgroup CgroupSpec // Cgroup to use for the container diff --git a/e2e/tests/container_create.go b/e2e/tests/container_create.go index a4ebe38..957ed21 100644 --- a/e2e/tests/container_create.go +++ b/e2e/tests/container_create.go @@ -438,6 +438,7 @@ func ContainerCreate(opt *option.Option) { options.HostConfig.DNS = []string{"8.8.8.8"} options.HostConfig.DNSOptions = []string{"test-opt"} options.HostConfig.DNSSearch = []string{"test.com"} + options.HostConfig.ExtraHosts = []string{"test-host:127.0.0.1"} // create container statusCode, ctr := createContainer(uClient, url, testContainerName, options)