docker-compose fails at adding veth (virtual interface) to bridge docker0
<p><strong>Issue</strong>:<br>
Here's my <code>docker-compose.yaml</code>:</p>

<pre><code>version: '2'

services:
    elasticsearch:
        image: 'elasticsearch:latest'
        ports:
            - "9200:9200"

    logstash:
        build: './logstash_image'
        links:
            - elasticsearch
        ports:
            - "5000:5000"
            - "5001:5001"
            - "5201:5201"
            - "5202:5202"
            - "5203:5203"

    kibana:
        image: 'kibana:latest'
        ports:
             - '5601:5601'
        links:
             - elasticsearch
        volumes:
             - ./kibana.yml:/opt/kibana/config/kibana.yml
</code></pre>

<p>And here's my <code>Dockerfile</code>:</p>

<pre><code>FROM logstash:latest

LABEL maintainer1.name="anon" \
      maintainer1.email="anon@mail.com" \
      maintainer2.name="myname" \
      maintainer2.email="myname@somemail.com"

RUN /opt/logstash/bin/logstash-plugin install logstash-input-log4j2-logstash2 logstash-output-syslog
# FIX: use `logstash-input-log4j2` instead of `logstash-input-log4j2-logstash2`?
# other plugins: logstash-input-http, logstash-input-log4j
COPY logstash.conf /etc/logstash/conf.d/logstash.conf

ENTRYPOINT ["logstash","-f","/etc/logstash/conf.d/logstash.conf", "--debug"]
</code></pre>

<p>This used to build just fine a few days ago, however currently I'm getting the following error message:</p>

<pre><code>[root@somemachine elk_stack]# docker-compose up -d
Creating network "elkstack_default" with the default driver
Building logstash
Step 1 : FROM logstash:latest
 ---&gt; 1ca34df702f8
Step 2 : LABEL maintainer1.name ...
 ---&gt; Using cache
 ---&gt; 6dd78ac216f2
Step 3 : RUN /opt/logstash/bin/logstash-plugin install logstash-input-log4j2-logstash2 logstash-output-syslog
 ---&gt; Running in 885b0429b3a4
ERROR: Service 'logstash' failed to build: failed to create endpoint focused_almeida on network bridge: adding interface veth0491201 to bridge docker0 failed: operation not supported
</code></pre>

<p><strong>ERROR: Service 'logstash' failed to build: failed to create endpoint focused_almeida on network bridge: adding interface veth0491201 to bridge docker0 failed: operation not supported</strong>  </p>

<p>So it seems like (1) docker-compose is assigning a randomly generated name to the logstash service instead of <code>elkstack_logstash_1</code> presumably because the compose did not fully go through.<br>
(2) <code>veth0491201</code> is unable to attach to the bridge <code>docker0</code> for some reason, because of this I can't reach the internet from within the container as it's not connected through <code>docker0</code>.</p>

<p><strong>Investigation</strong>:<br>
<code>docker ps -a</code> after the compose:</p>

<pre><code>CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                                        NAMES
885b0429b3a4        6dd78ac216f2                "/bin/sh -c '/opt/log"   18 minutes ago      Created                                                          focused_almeida
</code></pre>

<p><code>docker network ls</code> after the compose:</p>

<pre><code>NETWORK ID          NAME                          DRIVER            
23bcc8c01ad4        bridge                        bridge              
4aea66903c6b        none                          null                
67cb26c508d9        host                          host                
9fc4a42bbcf6        elkstack_default              bridge  
</code></pre>

<p><code>docker network inspect elkstack_default</code>:</p>

<pre><code>[
    {
        "Name": "elkstack_default",
        "Id": "9fc4a42bbcf6800889f8e9bc71ab394ebf6f97b21e0ce2345253b055d17138aa",
        "Scope": "local",
        "Driver": "bridge",
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.19.0.0/16",
                    "Gateway": "172.19.0.1/16"
                }
            ]
        },
        "Containers": {},
        "Options": {}
    }
]
</code></pre>

<p><code>route -n</code>:</p>

<pre><code>Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.120.1      0.0.0.0         UG    100    0        0 docker0
10.0.120.0      0.0.0.0         255.255.255.0   U     100    0        0 docker0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-83e64c848669
172.19.0.0      0.0.0.0         255.255.0.0     U     0      0        0 br-9fc4a42bbcf6
</code></pre>

<p><strong>Troubleshooting leads</strong>:</p>

<ol>
<li><code>docker --version</code>: Docker version 1.10.2, build c3959b1<br>
<code>docker-compose --version</code>: docker-compose version 1.8.0, build f3628c7<br>
Some networking bug in Docker?</li>
<li>The machine at which I'm doing this has recently done some config changes in regards to its network, firewalls etc.<br>
<strong>I think it's using <code>172.18.0.0</code> for something else, so when Docker tries to use that route it gets blocked.</strong>
How can I troubleshoot or determine if it's an issue with the machines network settings?</li>
<li>Following up on point made in (2), I tried to make a docker-compose where the network is explicitly defined, this didn't seem to work either:</li>
</ol>

<blockquote>
<pre><code>networks:
    net:
        driver: bridge
        ipam:
            driver: default
            config:
            - subnet: 172.30.0.0/16
              ip_range: 172.30.5.0/24
</code></pre>
</blockquote>

<ul>
<li>I'm able to docker-compose another stack of services on the machine, this leads me to believe that it's a Docker-related or docker-compose-related flaw, either in the application itself or my configuration.</li>
<li><p>I'm able to get this to work on my local machine, this leads me to believe that it's an issue with the remote machine where I'm having issues.  </p>

<p>uname -a: <code>Linux somemachine 3.10.0-327.10.1.el7.x86_64 #1 SMP Tue Feb 16 17:03:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux</code><br>
cat /etc/centos-release: <code>CentOS Linux release 7.2.1511 (Core)</code></p></li>
</ul>

<p><strong>Related info &amp; issues:</strong><br>
 - <a href="http://54.71.194.30:4017/articles/networking/#how-docker-networks-a-container">http://54.71.194.30:4017/articles/networking/#how-docker-networks-a-container</a><br>
 - <a href="https://github.com/docker/docker/issues/23047">https://github.com/docker/docker/issues/23047</a><br>
 - <a href="https://github.com/docker/docker/issues/15341">https://github.com/docker/docker/issues/15341</a></p>