Skip to content

Commit

Permalink
Warn if ulimit -n is too high when running Docker
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
  • Loading branch information
VietND96 committed Dec 11, 2023
1 parent 9f187e0 commit eda48ff
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Base/Dockerfile
Expand Up @@ -147,4 +147,13 @@ USER ${SEL_UID}:${SEL_GID}
# Boolean value, maps "--bind-host"
ENV SE_BIND_HOST false

# A too high maximum number of file descriptors (with the default value
# inherited from the docker host) can cause issues with some of our tools:
# - sanitizers hanging: https://github.com/google/sanitizers/issues/1662
# - valgrind crashing: https://stackoverflow.com/a/75293014
# This is not be a problem on our CI hosts, but developers who run the image
# on their machines may run into this (e.g., on Arch Linux), so warn them.
# (Note that .bashrc is only executed in interactive bash shells.)
RUN echo 'if [[ $(ulimit -n) -gt 200000 ]]; then echo "WARNING: Very high value reported by \"ulimit -n\". Consider passing \"--ulimit nofile=32768\" to \"docker run\"."; fi' >> ${HOME}/.bashrc

CMD ["/opt/bin/entry_point.sh"]

3 comments on commit eda48ff

@diemol
Copy link
Member

@diemol diemol commented on eda48ff Dec 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the image is already built, they are not running this again, right?

@VietND96
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When image is build, this step will append this script to .bashrc only. After that when container is running that's executed when a user logs in (exec to the container)

docker exec -it confident_kapitsa bash
WARNING: Very high value reported by "ulimit -n". Consider passing "--ulimit nofile=32768" to "docker run".
seluser@5b29025f8fd3:/$ 

When user notice this message, they can run the container again with suggest passing --ulimit

docker run -d -p 4444:4444 --user=2005 --ulimit nofile=32768 selenium/standalone-chrome:4.16.1-20231211

Now limit under control, hence that message is not appear when user exec to container anymore

docker exec -it zen_brown bash
seluser@0681e04cd767:/$

Do you think is this fine and helpful?

@diemol
Copy link
Member

@diemol diemol commented on eda48ff Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying, I missed the bashrc part. Makes sense.

Please sign in to comment.