Can't run as root
Describe the bug
I can't run commands as root or use su.
On default PHP simple stack, this happens:
bash-4.4 /projects $ sudo su
bash: sudo: command not found
bash-4.4 /projects $ su
su: must be run from a terminal
On default Python stack, I can run su, but I can't use it because I don't know the password:
bash-5.0 /projects $ sudo su
bash: sudo: command not found
bash-5.0 /projects $ su
Password:
su: Authentication failure
Expected behavior
I should be able to run commands as root or use su.
Steps to reproduce
Runtime
- Simple PHP stack
- Python stack
Environment
Che version
Che-Theia@ad8e4f4 using Theia@f255f5a8
It isn't supposed to run anything in behalf of root user. If you need something you have to use a dockerimage with preinstalled software and add it to your workspace configuration (or replace).
components:
- mountSources: true
type: dockerimage
alias: dev
image: '<YOUR_IMAGE>'
It isn't supposed to run anything in behalf of root user.
Why? It is useful if you want to quickly install some packages, change some configuration, run other commands...
In previous Che versions (actually Codenvy.io), root also worked.
Since containers are immutable, installing packages into a container is a strange use-case -- you would have to redo it on every startup. The recommended flow in docker is to configure your container to have all required packages installed in the image itself.
Further, containers as root is a significant security risk, so it is generally not supported by default in Che (it's not even possible to do on OpenShift, and advised against in Kubernetes).
The recommended flow in docker is to configure your container to have all required packages installed in the image itself.
How can I configure a container to install packages in the image itself?
Is the only solution (that works on OpenShift) to create an image and publish it to Docker Hub? Or is there any other solution which doesn't require to publish images to Docker Hub?
Publically releasing new image version each time you want to change/add some system package isn't the best solution...
Since containers are immutable, installing packages into a container is a strange use-case -- you would have to redo it on every startup.
Actually, in Codenvy.io, there was some feature/bug that allowed you to save snapshot of container and restore it on next startup.
I agree that installing packages after container was built is not the best solution, but having to additionally publish images to Docker Hub is also quite complicating.
The typical way to include packages in an image is to install them at image build time, e.g. the plugin registry requires a few packages.
For running on a cluster (be it k8s or OpenShift), you'll in general need to make an image available somewhere -- it doesn't have to be dockerhub; you can always deploy your own container regiistry or use e.g. quay.io. In some cases, you can use the cluster's internal registry, but that is more error prone in general. If you are concerned about publicly sharing your images, dockerhub allows one private repository.
Publically releasing new image version each time you want to change/add some system package isn't the best solution...
You don't need to release a completely new image, tags on containers are mutable; for instance, image quay.io/eclipse/che-machine-exec:nightly is updated every day and devfiles in the nightly builds of the Che devfile registry also reference nightly builds of images. One of the main benefits of containers is that they can independently -- if you and I both pull the machine-exec image, we'll be running the same environment. For example, I use the amisevsk/che-server:dev for all of my development in Eclipse Che.
we need to be able to run as root.
Setting CHE_INFRA_KUBERNETES_POD_SECURITY__CONTEXT_RUN__AS__USER=0 works
Issues go stale after 180 days of inactivity. lifecycle/stale issues rot after an additional 7 days of inactivity and eventually close.
Mark the issue as fresh with /remove-lifecycle stale in a new comment.
If this issue is safe to close now please do so.
Moderators: Add lifecycle/frozen label to avoid stale mode.
we need to be able to run as root. Setting
CHE_INFRA_KUBERNETES_POD_SECURITY__CONTEXT_RUN__AS__USER=0works
How did you implement it? Can you kindly let me know? I am using operator type installer.
we need to be able to run as root. Setting
CHE_INFRA_KUBERNETES_POD_SECURITY__CONTEXT_RUN__AS__USER=0works
@mingfang Can you please let me know how you achieved this?
@sushant08 Hope the following doc will help you https://www.eclipse.org/che/docs/che-7/advanced-configuration-options-for-the-che-server-component/
@sushant08 I deploy Eclipse Che using my own Terraform plugin https://github.com/mingfang/terraform-provider-k8s and module https://github.com/mingfang/terraform-k8s-modules/tree/master/modules/eclipse-che.
Here is the specific lines that configures it to run workspaces as root. https://github.com/mingfang/terraform-k8s-modules/blob/master/examples/eclipse-che/main.tf#L51
I think I'm confused, so eclipse-che is not useful for tinkering with systems before you make them docker images?