Docker starts 5 docker processes

April 28, 2015 647 views
Docker System Tools Ubuntu

I'm using the Docker default one-click-install from DO. If I restart my droplet, There are 5 docker processes running. My pstree looks something like this.

~# pstree -p
init(1)─┬─acpid(971)
        ├─atd(973)
        ├─cron(972)
        ├─dbus-daemon(741)
        ├─docker(1709)─┬─{docker}(1715)
        │              ├─{docker}(1717)
        │              ├─{docker}(1718)
        │              ├─{docker}(1719)
        │              └─{docker}(1720)
        ├─getty(931)
        ├─getty(934)
        ├─getty(939)
        ├─getty(940)
        ├─getty(942)
        ├─getty(1565)
        ├─nginx(1021)───nginx(1022)
        ├─rsyslogd(850)─┬─{rsyslogd}(851)
        │               ├─{rsyslogd}(852)
        │               └─{rsyslogd}(853)
        ├─sendmail-mta(1491)
        ├─sshd(966)───sshd(1348)───bash(1406)───pstree(1748)
        ├─systemd-logind(843)
        ├─systemd-udevd(385)
        ├─upstart-file-br(878)
        ├─upstart-socket-(680)
        └─upstart-udev-br(371)

The problem is that if I have multiple containers running, they will also run 5x times and create a lot of unnecessary processes. Because of that, I'm have to use a 10gb droplet that runs out of memory very quickly, despite getting almost no traffic.

This is how my pstree looks like after building and running a container.

~# pstree -p
init(1)─┬─acpid(971)
        ├─atd(973)
        ├─cron(972)
        ├─dbus-daemon(741)
        ├─docker(1709)─┬─docker(1985)─┬─{docker}(1986)
        │              │              ├─{docker}(1987)
        │              │              ├─{docker}(1988)
        │              │              ├─{docker}(1989)
        │              │              └─{docker}(1990)
        │              ├─ghost-start(1991)───su(2022)───bash(2023)───npm(2024)─┬─sh(2030)───node(2031)─┬─{node}(2032)
        │              │                                                       │                       ├─{node}(2033)
        │              │                                                       │                       ├─{node}(2034)
        │              │                                                       │                       ├─{node}(2035)
        │              │                                                       │                       └─{node}(2036)
        │              │                                                       ├─{npm}(2025)
        │              │                                                       ├─{npm}(2026)
        │              │                                                       ├─{npm}(2027)
        │              │                                                       ├─{npm}(2028)
        │              │                                                       └─{npm}(2029)
        │              ├─{docker}(1715)
        │              ├─{docker}(1717)
        │              ├─{docker}(1718)
        │              ├─{docker}(1719)
        │              ├─{docker}(1720)
        │              ├─{docker}(1910)
        │              ├─{docker}(1911)
        │              ├─{docker}(1912)
        │              ├─{docker}(2013)
        │              └─{docker}(2016)
        ├─getty(931)
        ├─getty(934)
        ├─getty(939)
        ├─getty(940)
        ├─getty(942)
        ├─getty(1565)
        ├─nginx(1021)───nginx(1022)
        ├─rsyslogd(850)─┬─{rsyslogd}(851)
        │               ├─{rsyslogd}(852)
        │               └─{rsyslogd}(853)
        ├─sendmail-mta(1491)
        ├─sshd(966)───sshd(2037)───bash(2085)───pstree(2100)
        ├─systemd-logind(843)
        ├─systemd-udevd(385)
        ├─upstart-file-br(878)
        ├─upstart-socket-(680)
        └─upstart-udev-br(371)

Docker version:

~# docker -v
Docker version 1.6.0, build 4749651

I'm using fig 1.0.0 (Should probably switch to docker-compose).

Question

What's the best way to reduce the number of processes to just one? Why are there 5 docker processes running? Is there a reason this was setup this way in the first place?

1 Answer

Hello,

This appears to be just how docker does things. Even when installing using their official documentation (found here) I'm getting a similar amount of processes running for docker.

As for why I'm having a hard time finding why. In generally with the DO One-clicks, there is very little modification to the base setup. In this case it's just installing docker for you.

Since I can't exactly find out why it spawns so many processes, I'm not entirely sure how to reduce those. As for the running out of memory, have you ensured the containers you are running to not require more memory?

I was running a few containers in my test setup and didn't really reach my memory limits. So it may be the specific containers you are running that require larger amounts of memory. MySQL, WordPress, Joomla and other Content Management systems can have a rather heavy footprint for memory out of the box. Even without traffic they can sometimes crash a system just due to the resources they require on their own.

Have another answer? Share your knowledge.