Distcc in docker causing memory leaks

I want to use distcc inside docker to compile c++ but there are huge memory leaks. And the used memory is never free, even if I stop the container or the docker daemon.

I’m using this Dockerfile with Tini:

  • Why can't I “freopen” a “tmpfile”?
  • Keep a self hosted servicestack service open as a docker swarm service without using console readline or readkey
  • Running Grapevine REST server in Mono Docker container
  • .Net - Pushing logs from web application to Docker container running Fluentd
  • How to set specs file for gcc in Docker container
  • Identity Server 4 running within docker container Exception: Unable to load DLL 'System.Security.Cryptography.Native.OpenSsl'
  • FROM fedora:24
    RUN dnf install -y wget \
        gnupg \
        distcc-server \
        gcc-c++ && \
        dnf clean packages
    RUN useradd distcc
    # grab tini for signal processing and zombie killing
    RUN set -x \
        && wget -O /usr/local/bin/tini "https://github.com/krallin/tini/releases/download/$TINI_VERSION/tini" \
        && wget -O /usr/local/bin/tini.asc "https://github.com/krallin/tini/releases/download/$TINI_VERSION/tini.asc" \
        && export GNUPGHOME="$(mktemp -d)" \
        && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 6380DC428747F6C393FEACA59A84159D7001A4E5 \
        && gpg --batch --verify /usr/local/bin/tini.asc /usr/local/bin/tini \
        && rm -r "$GNUPGHOME" /usr/local/bin/tini.asc \
        && chmod +x /usr/local/bin/tini \
        && tini -h
    COPY docker-entrypoint.sh /
    EXPOSE 3632
    ENTRYPOINT ["/docker-entrypoint.sh"]

    And this entrypoint script:

    set -e
    set -- tini distccd -- "$@"
    exec "$@"

    My container starts well on my server:

    docker run -d -p 3632:3632 mydistcc --no-detach -a --verbose --log-stderr --jobs 8

    When I try to build any c++ repo from my workstation using my distcc server, the container will leak memory during the compilation. For example I’ve tried compiling OpenCV which leaks 1G per from scratch build:

    $ git clone https://github.com/opencv/opencv.git
    $ mkdir opencv/build && cd opencv/build
    $ DISTCC_HOSTS="mydistcc-server-ip/8" CXX="distcc g++" cmake ..
    $ DISTCC_HOSTS="mydistcc-server-ip/8" CXX="distcc g++" make -j 8

    If I run distcc-server natively on my server (without docker) I do not have any leak.

    What am I doing wrong with docker?

    Here is the docker info on my server:

    Containers: 0
     Running: 0
     Paused: 0
     Stopped: 0
    Images: 11
    Server Version: 1.10.3
    Storage Driver: devicemapper
     Pool Name: docker-253:0-2885180-pool
     Pool Blocksize: 65.54 kB
     Base Device Size: 10.74 GB
     Backing Filesystem: xfs
     Data file: /dev/loop0
     Metadata file: /dev/loop1
     Data Space Used: 4.514 GB
     Data Space Total: 107.4 GB
     Data Space Available: 42.87 GB
     Metadata Space Used: 5.03 MB
     Metadata Space Total: 2.147 GB
     Metadata Space Available: 2.142 GB
     Udev Sync Supported: true
     Deferred Removal Enabled: false
     Deferred Deletion Enabled: false
     Deferred Deleted Device Count: 0
     Data loop file: /var/lib/docker/devicemapper/devicemapper/data
     WARNING: Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt
    dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.
     Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
     Library Version: 1.02.122 (2016-04-09)
    Execution Driver: native-0.2
    Logging Driver: journald
     Volume: local
     Network: bridge null host
    Kernel Version: 4.8.13-200.fc24.x86_64
    Operating System: Fedora 24 (Workstation Edition)
    OSType: linux
    Architecture: x86_64
    Number of Docker Hooks: 2
    CPUs: 8
    Total Memory: 23.53 GiB
    Name: myserver
    Registries: docker.io (secure)

  • how to install/start docker engine service inside a docker container
  • monitoring docker container performance using cadvisor / cgroup, best approach
  • New to Docker - how to essentially make a cloneable setup?
  • Installing mongo client in a Docker container
  • How to install nvm in a Dockerfile?
  • How can I disable the default composer install in CircleCI?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.