Linux – /bin/bash: Resource temporarily unavailable in Docker when running Chrome

dockergoogle-chromelinux

I have a Docker container running Redhat:

Red Hat Enterprise Linux Server release 6.2 (Santiago)

Host OS is Linux Mint:

Linux Mint 19 Tara

When I run certain commands in it and Chrome is running on the host machine I get:

bash-4.1# su www
su: /bin/bash: Resource temporarily unavailable

When I close Chrome on the host machine the commands work as expected.

My thinking is I'm running into some kind of resource issue but I'm not sure where to look — which resource and is the issue in the OS on the Docker container or the host OS?

I thought it might be open files:

$ lsof | wc -l <-- With Chrome
311424
$ lsof | wc -l <-- Without Chrome
181608

But the max files on the host is set way above the open files with Chrome running:

$ cat /proc/sys/fs/file-max
3264936

Memory doesn't seem to be an issue either:

$ free -g <-- With Chrome
              total        used        free      shared  buff/cache   available
Mem:             31           8           5           2          17          19
Swap:             1           0           1

$ free -g <-- Without Chrome
              total        used        free      shared  buff/cache   available
Mem:             31          11           2           2          17          16
Swap:             1           0           1

Where else should I be looking?

Update

baelx has the correct answer but there's some additional resources that may help other people in the future.

This article has some good information on finding the number of processes each user is running.

$ ps h -Led -o user | sort | uniq -c | sort -n

It's also important to note that the nproc command has nothing to do with the nproc.conf file.

This article has information on how host user ids map to container user ids. In my case, my user on the host has a user id of 1000. The www user on the host has a user id also of 1000. With Chrome having open 1600+ processes on the host owned by user id 1000 (jbodnar) the container couldn't open another process for user id 1000 (www).

Best Answer

You might be hitting your system's max PID or its ulimit. You can see how many total processes are running with:

ps -eLf | wc -l

If the above result is 32,000, then increase kernel.pid_max to 65,534. Your system will only support this increase if it's a 64-bit system, mind you. You can use the sysctl command to achieve this:

sysctl -w  kernel.pid_max=65534

At this point try to run the su command again. If that's not working then have a look at Chrome's number of running processes:

ps -eLf | grep chrome | wc -l

You could then try to modify Chrome's nproc number within /etc/security/limits.conf - although this might need to be done through /etc/security/limits.d/90-nproc.conf for RHEL 6.

Each file should use the same syntax to describe the amount of open processes. You can try changing Chrome's value from 1024 to 2048(or possibly greater if the issue merrits it). You could also try adjusting this value for all users(denoted by the star):

<user>       -          nproc     2048      <<<----[ Only for "<user>" user ]
  *          -          nproc     2048      <<<----[ For all user's ]

Source

(If you don't have an account there, I'd recommend it since there's lots of good educational and support material there.)

Related Question