Skip to content

Container not attached to network when hostconfig specified on start instead of create #19100

@vikstrous

Description

@vikstrous

We have a tool that interacts with the docker API directly and it started failing on master (aka 1.10, aka 723be0a). It tries to start containers with a custom network using the NetworkMode parameter in the start API. There is a warning that this will be removed in 1.12, but it looks like it already doesn't work for NetworkMode.

Example docker log when this fails:

DEBU[0061] Calling POST /v1.13/containers/create        
DEBU[0061] POST /v1.13/containers/create?name=(redacted) 
DEBU[0061] form data: {"AttachStderr":false,"AttachStdin":false,"AttachStdout":false,"Env":["NO_PROXY=(redacted)","HTTPS_PROXY=","HTTP_PROXY="],"Image":"(redacted):(redacted)","Memory":0,"MemorySwap":0,"NetworkDisabled":false,"OpenStdin":false,"StdinOnce":false,"Tty":false}
DEBU[0061] container mounted via layerStore: /var/lib/docker/overlay/a231abd7438a8a6dc86f68fe0e7abba14a63f89a00aa8076f3b88a0f23c2bb90/merged 
DEBU[0061] Incrementing volume reference: driver local, name cc80f3f57a0a9b57e3d787c5062f37497732f0cc2da1874c031fc3290bb85e3c 
DEBU[0061] Calling GET /v1.13/containers/json           
DEBU[0061] GET /v1.13/containers/json?all=1&limit=-1&trunc_cmd=1&size=0 
DEBU[0061] Calling GET /v1.13/containers/json           
DEBU[0061] GET /v1.13/containers/json?all=0&limit=-1&trunc_cmd=1&size=0 
DEBU[0061] Calling POST /v1.13/containers/(redacted)/start 
DEBU[0061] POST /v1.13/containers/(redacted)/start 
DEBU[0061] form data: {"Binds":["/var/(redacted):/var/(redacted):rw"],"NetworkMode":"(redacted)","PortBindings":{},"RestartPolicy":{"MaximumRetryCount":0,"Name":"always"},"SecurityOpt":["label:type:(redacted)"]} 
WARN[0061] DEPRECATED: Setting host configuration options when the container starts is deprecated and will be removed in Docker 1.12 
DEBU[0061] Decrementing volume reference: driver local, name cc80f3f57a0a9b57e3d787c5062f37497732f0cc2da1874c031fc3290bb85e3c 
DEBU[0061] container mounted via layerStore: /var/lib/docker/overlay/a231abd7438a8a6dc86f68fe0e7abba14a63f89a00aa8076f3b88a0f23c2bb90/merged 
DEBU[0061] Assigning addresses for endpoint (redacted)'s interface on network bridge 
DEBU[0061] RequestAddress(LocalDefault/172.17.0.0/16, <nil>, map[])

Expected result: Container starts attached to the custom network
Actual result: Container starts on the default "bridge" network

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/apiAPIarea/networkingNetworkingkind/bugBugs are bugs. The cause may or may not be known at triage time so debugging may be needed.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions