-
Notifications
You must be signed in to change notification settings - Fork 235
Reference the numerical UID for the Docker images to run as. #219
base: master
Are you sure you want to change the base?
Conversation
Just a note on this.. I'm not overly keen on specifying the ID for the mysql user directly in the Dockerfile as that user is created via package install in the source image (we don't have control on the id for the user, unless we create a new different user and chown file permissions). Unfortunately there doesn't appear to be a way to export the value of a RUN command (such as MYSQL_UID=`docker run --entrypoint id mysql/mysql-server:8.0.12 -u mysql`
docker build --build-arg MYSQL_UID=${MYSQL_UID} -t mysql-agent -f docker/mysql-agent/Dockerfile . If that is preferred, let me know and I can change the approach in the PR. |
@KashifSaadat Would using https://github.com/tianon/gosu / https://github.com/ncopa/su-exec in an entrypoint script solve the issue without requiring the hardcoding of a uid we don't control? |
Hey @prydie, unfortunately no. The code in Kubernetes for A user can get around this by defining the securityContext in their PodSpec similar to below (which takes precedence over the check on the ImageSpec): securityContext:
runAsUser: 27 |
I have added a second commit to avoid hardcoding the UID for the Just more bash in the Makefile unfortunately. |
@KashifSaadat Currently the project For your change to have any effect on the release / CI images we need to change how we build images in the Wercker pipeline (see: here). Are you interested in giving it a shot? |
Hey @prydie, I've never used wercker before but given it a go, commits (I can squash / cleanup once we have the right approach): Could you suggest the best way to validate this? I've added and reworked the existing build pipelines, although I can't seem to see the new steps being executed or the log output of |
I've activated the repo in wercker for my fork to attempt to debug this further, ran into a few issues:
Any thoughts? |
Signed-off-by: Kashif Saadat <[email protected]>
mysql-agent image, rather than hardcoding a UID in the Dockerfile. Signed-off-by: Kashif Saadat <[email protected]>
Signed-off-by: Kashif Saadat <[email protected]>
Signed-off-by: Kashif Saadat <[email protected]>
dae9709
to
7aeaa2e
Compare
In Kubernetes when making use of PodSecurityPolicies with
MustRunAsNonRoot
set, the kubelet rejects any pods with a non-numeric USER.Changes:
mysql-agent
image, reference the numerical id for the mysql user (created as part of the package install in the source image)mysql-operator
image, create and reference a non-root user to run the image with