Cannot run systemctl command

Hi,

First thanks for this framework, it seems amazing !

I wanted to run a docker image for some python code which need elastic search.

As I understood I cannot run another docker for elasticsearch.
So I tried to install it from the docker image

However, I need to enable and start the daemon for that which doesn’t work…

Here is my dockerfile with some of my tries…
NB apt-get command are run with sudo if user is gitpod

FROM gitpod/workspace-full

# USER gitpod  // sudo: setrlimit(RLIMIT_CORE): Operation not permitted // 
USER root // build failed: cannot build base image: The command '/bin/sh -c systemctl start elasticsearch' returned a non-zero code: 1 //

# Try to fix sudo bug (https://github.com/sudo-project/sudo/issues/42#issuecomment-609079906)
# RUN sudo echo "Set disable_coredump false" >> /etc/sudo.conf  // Permission denied //

# Add keys
RUN curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
RUN echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-7.x.list

# Update
RUN apt-get update && apt-get upgrade -y

# Install elasticsearch and enable it
RUN apt install -y elasticsearch
RUN systemctl start elasticsearch
RUN systemctl enable elasticsearch

Else I’m thinking about using two FROM clause one for gitpod the other for elasticsearch.

Thanks in advance for your time,

We are going to support running docker pretty soon (beta this year). In the meantime you can echo the startup commands into .bashrc.

Here’s an example: https://github.com/gitpod-io/workspace-images/blob/master/postgres/Dockerfile#L24

Hi @svenefftinge,

Thanks a lot for the reply !

I tried what you said, however it wouldn’t start elasticsearch so I tried manually in my gitpod instance terminal :

systemctl enable elasticsearch
---->
Synchronizing state of elasticsearch.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable elasticsearch
update-rc.d: error: unable to read /etc/init.d/elasticsearch
systemctl start elasticsearch
---->
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
sudo systemctl enable elasticsearch or sudo systemctl start elasticsearch
---->
sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?

I also try with a SysV init like (instead of SystemD) without succes

sudo update-rc.d elasticsearch defaults 95 10 // update-rc.d: error: unable to read /etc/init.d/elasticsearch
sudo -i service elasticsearch start // sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?
service elasticsearch start // elasticsearch: unrecognized service

I will be happy to find a temporary hack to run elasticsearch while waiting for the beta.

Thanks in advance

Hi @Ierezell,
you try to start elasticsearch using systemd which is an init system for operating systems and it is not present by design in a docker image. As gitpod is runing as a pod in Kubernetes and therefore using conainter images, your approach have to be different. Either you start elasticsearch manually in your workspace with the command or you embed it in a script that runs on every time a workspace is started using the gitpod.yaml (docs).

Hi @wulfthimm,

Thanks a lot, now that you’re saying it I realize it was stupid to try that.
I was confused with the .bashrc hack above.

Anyway, everything seems working now,

Thanks for your help.
Have a good day :slight_smile:

Hi @Ierezell,
I have also tried that, that is why I know that. :wink:
Have a nice day too
Wulf