Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a numeric USER instruction in Dockerfiles #1073

Closed
wants to merge 1 commit into from
Closed

Use a numeric USER instruction in Dockerfiles #1073

wants to merge 1 commit into from

Conversation

srguglielmo
Copy link
Contributor

@srguglielmo srguglielmo commented Jun 30, 2020

Description

By using a numeric USER instruction in Dockerfiles, the images are now able to pass a strict Kubernetes securityContext configuration. Specifically, runAsNonRoot, which requires a numeric user/group ID. It is also a Docker best practice. The values of 1200 and 1201 are arbitrary.

Motivation and Context

While running a Selenium grid cluster in Kubernetes, I noticed I was unable to run the images with runAsNonRoot: true due to the following error:

CreateContainerConfigError: container has runAsNonRoot and image has non-numeric user (seluser), cannot verify user is non-root

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Here's an example of the k8s config that runs successfully after this patch:

apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      containers:
      - name: hub
        image: selenium/hub:local
        securityContext:
          allowPrivilegeEscalation: false
          capabilities:
            drop:
            - ALL
          privileged: false
          readOnlyRootFilesystem: false
          runAsNonRoot: true

I can run VERSION=local make build locally successfully. Let me know if there's anything I can change or if this can be tested somehow.

Thanks,
Steve

@CLAassistant
Copy link

CLAassistant commented Jun 30, 2020

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

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

Thank you for this PR @srguglielmo!
I added a comment several times.

Could you please send this PR to the https://github.com/SeleniumHQ/docker-selenium/tree/selenium-4-alpha branch too?

@@ -5,7 +5,7 @@
FROM selenium/base:3.141.59-20200525
Copy link
Member

Choose a reason for hiding this comment

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

Could you please only change the Dockerfile.txt files?

@@ -75,7 +75,7 @@ RUN apt-get -qqy update \
# Run the following commands as non-privileged user
Copy link
Member

Choose a reason for hiding this comment

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

Could you please only change the Dockerfile.txt files?

@@ -32,7 +32,7 @@ RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key
COPY wrap_chrome_binary /opt/bin/wrap_chrome_binary
RUN /opt/bin/wrap_chrome_binary

USER seluser
USER 1200
Copy link
Member

Choose a reason for hiding this comment

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

Could you please only change the Dockerfile.txt files?

@@ -24,7 +24,7 @@ RUN apt-get update -qqy \
fluxbox \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*

USER seluser
USER 1200
Copy link
Member

Choose a reason for hiding this comment

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

Could you please only change the Dockerfile.txt files?

@@ -37,7 +37,7 @@ RUN GK_VERSION=$(if [ ${GECKODRIVER_VERSION:-latest} = "latest" ]; then echo "0.
&& chmod 755 /opt/geckodriver-$GK_VERSION \
&& ln -fs /opt/geckodriver-$GK_VERSION /usr/bin/geckodriver

USER seluser
USER 1200

Copy link
Member

Choose a reason for hiding this comment

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

Could you please only change the Dockerfile.txt files?

@@ -5,7 +5,7 @@
FROM selenium/node-chrome-debug:3.141.59-20200525
LABEL authors=SeleniumHQ

USER seluser
USER 1200

Copy link
Member

Choose a reason for hiding this comment

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

Could you please only change the Dockerfile.txt files?

@@ -5,7 +5,7 @@
FROM selenium/node-firefox:3.141.59-20200525
LABEL authors=SeleniumHQ

USER seluser
USER 1200

Copy link
Member

Choose a reason for hiding this comment

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

Could you please only change the Dockerfile.txt files?

@@ -5,7 +5,7 @@
FROM selenium/node-firefox-debug:3.141.59-20200525
LABEL authors=SeleniumHQ

USER seluser
USER 1200

Copy link
Member

Choose a reason for hiding this comment

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

Could you please only change the Dockerfile.txt files?

@@ -5,7 +5,7 @@
FROM selenium/node-opera:3.141.59-20200525
LABEL authors=SeleniumHQ

USER seluser
USER 1200

Copy link
Member

Choose a reason for hiding this comment

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

Could you please only change the Dockerfile.txt files?

@@ -5,7 +5,7 @@
FROM selenium/node-opera-debug:3.141.59-20200525
LABEL authors=SeleniumHQ

USER seluser
USER 1200

Copy link
Member

Choose a reason for hiding this comment

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

Could you please only change the Dockerfile.txt files?

Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

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

Meant to request changes not approve.

@srguglielmo
Copy link
Contributor Author

Replaced this PR with #1082 (master) and #1083 (selenium-4-alpha).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants