# Docker mtu problem

**URL:** <https://drone.discourse.group/t/docker-mtu-problem/11246>\
**Category:** Drone Support\
**Created:** [December 8, 2017, 7:01am UTC](https://drone.discourse.group/t/docker-mtu-problem/11246 "2017-12-08T07:01:49Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![donghuabin72](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/donghuabin72/32/3918_2.png) [@donghuabin72](https://drone.discourse.group/u/donghuabin72)\
**Post date:** [December 8, 2017, 7:01am UTC](https://drone.discourse.group/t/docker-mtu-problem/11246/1 "2017-12-08T07:01:49Z")

</div>

The environment I use is openstack vm, The network card mtu is 1454 ,not 1500  
When I build with drone, I find that it creates a new container and the mtu of the network card  
is 1500 . so the container was not able to access the Internet

by the way ,during the use, I discovered that the drone created a bridge network using docker and the mtu is 1500, I need to set the mtu of this network for 1400 to get online

I’ve done the following, but it doesn’t work

networks:  
default:  
driver: bridge  
driver\_opts: io.drone.network.pod=true

My drone version is 0.8.1

What else do I need to write, thank you.

---

<div class="post-metadata">

**Author:** ![zaggash](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/zaggash/32/3624_2.png) [@zaggash](https://drone.discourse.group/u/zaggash)\
**Post date:** [December 11, 2017, 1:20am UTC](https://drone.discourse.group/t/docker-mtu-problem/11246/2 "2017-12-11T01:20:55Z")

</div>

You can try to change the docker daemon setting by modifying `/etc/docker/daemon.json` with :

```auto
{
'mtu': '1400'
}

```

or change direcetly the value in you compose file in the network section :

```auto
networks:
  default:
    driver: bridge
    driver_opts:
      com.docker.network.driver.mtu: 1400

```

---

<div class="post-metadata">

**Author:** ![arhont375](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/arhont375/32/3761_2.png) [@arhont375](https://drone.discourse.group/u/arhont375)\
**Post date:** [December 23, 2017, 5:03pm UTC](https://drone.discourse.group/t/docker-mtu-problem/11246/3 "2017-12-23T17:03:17Z")

</div>

Actually it’s not exactly Drone issues, but Docker (not possible to set default MTU for all new networks). Even if you will change MTU settings in `daemon.json` it will be applied only to default bridge. Settings inside `docker-compose.yml` will be applied only to networks that was created for drone-server/agent. But Drone will create additional network and that network will have default MTU 1500. So in result I end up with modifying Drone source code to be able to pass network options to this Drone-created network.

And I want to ask you @bradrydzewski do you interested in such Pull Request to 2 repos: `drone/drone` and `cncd/pipeline` to add ability to pass options for Drone created networks?

---

<div class="post-metadata">

**Author:** ![arno01](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/arno01/32/4171_2.png) [@arno01](https://drone.discourse.group/u/arno01)\
**Post date:** [January 15, 2018, 11:59pm UTC](https://drone.discourse.group/t/docker-mtu-problem/11246/4 "2018-01-15T23:59:19Z")

</div>

I am having the same issue. I am running Drone `0.8.2` inside the OpenStack VM which runs the Kubernetes with Weave Net CNI (Container Network Interface) which is running with the MTU of `1360` bytes.

At first, I thought that having the `--mtu` set to `1360` bytes for the `drone-dind` (`docker:17.12.0-ce-dind`) would have solved the issue, only if it was keeping that `--mtu=1360` as the default for the newly created docker network bridges. Unfortunately, this is not the case [1].

I believe this should not be very hard to extend the Drone and let the users set their options such as the MTU value for the Docker network [2].

At the moment, my quick and dirty workaround is to leverage the “clamp the MSS” (Linux kernel feature in the network stack that calculates the proper MSS for the link) [3].

This is the piece of my configuration for the Kubernetes deployment:

> I am using the DOCKER-USER iptables chain as the Docker is trying to place it as the first rule under the FORWARD chain.
> 
> Please also note that I am using `--host=tcp://127.0.0.1:2375` instead of `--host=tcp://0.0.0.0:2375` dockerd argument as the latter one allows an unprivileged container (ran in Drone) to escape to the drone-dind.

```auto
      - name: drone-dind
        image: "docker:17.12.0-ce-dind"
        imagePullPolicy: IfNotPresent
        command: ["/bin/sh"]
        args: ["-c", "iptables -N DOCKER-USER; iptables -I DOCKER-USER -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu; dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375"]

```

- [1] [Docker network create doesn't inherit the MTU set in the Docker deamon · Issue #28314 · moby/moby · GitHub](https://github.com/moby/moby/issues/28314#issuecomment-260432029)
- [2] [https://github.com/drone/drone/blob/v0.8.3/vendor/github.com/cncd/pipeline/pipeline/frontend/yaml/compiler/compiler.go#L77-L81](https://github.com/drone/drone/blob/v0.8.3/vendor/github.com/cncd/pipeline/pipeline/frontend/yaml/compiler/compiler.go#L77-L81)
- [3] [Circumventing Path MTU Discovery issues with MSS Clamping (for ADSL, cable, PPPoE & PPtP users)](http://lartc.org/howto/lartc.cookbook.mtu-mss.html)

---

<div class="post-metadata">

**Author:** ![donghuabin72](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/donghuabin72/32/3918_2.png) [@donghuabin72](https://drone.discourse.group/u/donghuabin72)\
**Post date:** [January 16, 2018, 2:33am UTC](https://drone.discourse.group/t/docker-mtu-problem/11246/6 "2018-01-16T02:33:13Z")

</div>

Thank you. I’ve solved this problem by setting the **network\_mode** property

![cicd](https://canada1.discourse-cdn.com/flex003/uploads/testdrone/original/1X/18a304487f0e7e13577544dde5bb8d0350273b77.png)

---

<div class="post-metadata">

**Author:** ![donghuabin72](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/donghuabin72/32/3918_2.png) [@donghuabin72](https://drone.discourse.group/u/donghuabin72)\
**Post date:** [January 16, 2018, 2:35am UTC](https://drone.discourse.group/t/docker-mtu-problem/11246/7 "2018-01-16T02:35:34Z")

</div>

Thank you for your reply  
I’ve tried it, but it doesn’t work.

---

<div class="post-metadata">

**Author:** ![arno01](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/arno01/32/4171_2.png) [@arno01](https://drone.discourse.group/u/arno01)\
**Post date:** [January 16, 2018, 8:25am UTC](https://drone.discourse.group/t/docker-mtu-problem/11246/8 "2018-01-16T08:25:49Z")

</div>

The network\_mode property works only when you set the Trusted repo option which can only be done by Drone admin. Since the trusted repo also allows running containers in a privileged mode, this might not be a solution to many people, including me.

---

<div class="post-metadata">

**Author:** ![MarekSuchanek](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/mareksuchanek/32/3520_2.png) [@MarekSuchanek](https://drone.discourse.group/u/MarekSuchanek)\
**Post date:** [August 11, 2020, 5:46am UTC](https://drone.discourse.group/t/docker-mtu-problem/11246/9 "2020-08-11T05:46:04Z")

</div>

Hi, is there any solution for this in the current Drone CI? I am trying to run it using Docker Swarm on OpenStack where MTU is 1442. Then the runners always fail on fetching the repository 🤦‍♂️

```
Initialized empty Git repository in /drone/src/.git/
+ git fetch origin +refs/heads/drone:
fatal: unable to access 'https://github.com/MarekSuchanek/engine-backend.git/': LibreSSL 
SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
```

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [August 11, 2020, 1:09pm UTC](https://drone.discourse.group/t/docker-mtu-problem/11246/10 "2020-08-11T13:09:15Z")

</div>

I pushed [this patch](https://github.com/drone-runners/drone-runner-docker/commit/06b89a91b45d1dfb9743196f72bfdbc31b100f69) that allows you to set global docker network options. This patch is available in the latest version of the runner image. You can set global network options as follows:

```nohighlight
DRONE_RUNNER_NETWORK_OPTS=com.docker.network.drive.mtu:1442

```

This patch _should work_ based on the docker documentation, but I do not have an environment that I can use to test this. If you experience any issues we would kindly ask that you send a pull request that improves this code.

---

<div class="post-metadata">

**Author:** ![MarekSuchanek](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/mareksuchanek/32/3520_2.png) [@MarekSuchanek](https://drone.discourse.group/u/MarekSuchanek)\
**Post date:** [August 13, 2020, 2:40pm UTC](https://drone.discourse.group/t/docker-mtu-problem/11246/11 "2020-08-13T14:40:29Z")

</div>

Thanks! It worked for me, just I needed to use:

`DRONE_RUNNER_NETWORK_OPTS=com.docker.network.driver.mtu:1442`

(typo, driver instead of drive - if someone finds the solution here)

---

<div class="post-metadata">

**Author:** ![maximilize](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/maximilize/32/2214_2.png) [@maximilize](https://drone.discourse.group/u/maximilize)\
**Post date:** [December 20, 2021, 11:56pm UTC](https://drone.discourse.group/t/docker-mtu-problem/11246/12 "2021-12-20T23:56:08Z")

</div>

This works for the docker runner, but how about `docker exec`? When using a VPN locally, the MTU of the newly created docker networks always defaults to 1500.

---

<div class="post-metadata">

**Author:** ![Sbbh](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/sbbh/32/8892_2.png) [@Sbbh](https://drone.discourse.group/u/Sbbh)\
**Post date:** [May 7, 2023, 1:08pm UTC](https://drone.discourse.group/t/docker-mtu-problem/11246/13 "2023-05-07T13:08:24Z")

</div>

Did you ever get this sorted? I’m facing the same issue with newly created containers using a different docker network with MTU reverted back to 1500.
