• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Running Eclipse inside Docker
#1
Dear all,

I am using Rpi3 for building my custom image which I intend to run later on a Netpi. My requirement is to run Eclipse JDT on Net pi. So, I created a docker file with following commands in it.

------------------------------------------
FROM raspbian/stretch

RUN apt-get update
RUN apt-get install -y eclipse
RUN eclipse 
---------------------------------------------

Before trying out with docker, I downloaded, Eclipse JDT on to the same Rpi by using the above commands in the same sequence and every time, I give "eclipse" on my terminal, the Eclipse IDE opens up. Since my RPi's OS is raspbian stretch which is what I am using in my custom image as well, I used same commands in same sequence in my Docker file as well. When I build the Docker file, the first 3 steps worked well but there popped an error while at the last step. Error message attached in the picture for your reference. I am very new to Docker so, I think I am missing some basics here and couldnot get what I intend to. Any suggestions from you will be of great help to me. Thanks in advance.


Attached Files Thumbnail(s)
   
  Reply
#2
Well Rahul,

here is a general hint how I deal with non working commands while I have no idea why they don't work:

In such cases I go back to my Dockerfile and remove all lines that do not work correctly. Then I let Docker rebuild the image based on the working Dockerfile.

At the end I have a proper image as an output ... of course not the final one that I want ... but a working one.

Afterwards I am starting a container of this working image with the following command and "jump" into the image on console basis.


Code:
docker run -it --entrypoint=/bin/bash <image-name or image-id>


The -it option is very important since it redirects all consoles outputs and keystrokes of your container to the original host console you started on your raspberry.

You could for example reduce your Dockerfile to the absolute minimum like


Code:
FROM raspbian/stretch
RUN apt-get update
RUN apt-get install -y eclipse

 
then build it (-t command tags the image and give it a name)


Code:
docker build -t mycontainer .

then run it with


Code:
docker run -it --entrypoint=/bin/bash mycontainer

The --entrypoint option specifies the first command that is called when a container is started from an image and hence starts a shell console based on /bin/bash command.

Now you are "in" the container and you can try to run your initial "eclipse" command yourself that didn't work to understand why it does not work properly in the container. With this procedure you can stepwise try command, recheck them and find out the correct Linux commands. With this knowledge you can easily complete your Dockerfile with the correct command list. In Dockerfile you have just to add the preceeding "RUN" to each line.

Use the following command to exit the container:


Code:
exit
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#3
But let me ask you this about "Eclipse" in general: For me "Eclipse" is a workbench you usually control via a mouse and keyboard over a Desktop? Is my understanding correct?

So on your hosting RPI - where you say the installation works fine - which version of Raspbian are you running? Raspbian Stretch light or Raspian Desktop?

I did the same thing in your raspbian/strecht container and got exactly the same thing. When eclipse is failing starting it creates a log file.

This is the one I get:

org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
        at org.eclipse.swt.SWT.error(SWT.java:4387)
        at org.eclipse.swt.widgets.Display.createDisplay(Display.java:914)
        at org.eclipse.swt.widgets.Display.create(Display.java:900)
        at org.eclipse.swt.graphics.Device.<init>(Device.java:156)
        at org.eclipse.swt.widgets.Display.<init>(Display.java:498)
        at org.eclipse.swt.widgets.Display.<init>(Display.java:489)
        at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:716)
        at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:161)
        at org.eclipse.ui.internal.ide.application.IDEApplication.createDisplay(IDEApplication.java:154)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:96)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1414)

Looking on the internet for the error "org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]" I found that the java application has not found any graphical display and hence cannot be started. So my assumption is that your base image "raspbian/stretch" is no image with display/desktop function


Thx
Armin
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#4
As expected the missing graphical base system is the root cause of your problem.

For a test I loaded a Desktop image on my netPI from here https://cloud.docker.com/u/hilschernetpi...sktop-hdmi.

After I started a container of the image I opened a console on the screen under the default user "testuser" and called the commands:


Code:
> sudo apt-get update
> sudo apt-get install eclipse
> eclipse


Eclipse was starting right away and I was able to click the Eclipse Icons with my mouse.

So your choice using raspbian/stretch as base image is not feasible. I would write a Dockerfile like this instead:


Code:
FROM hilschernetpi/netpi-desktop-hdmi
USER testuser
RUN sudo apt-get update
RUN sudo apt-get install eclipse


This sequence combines both Desktop and Eclipse environment.

And starting Eclipse itself in a Dockerfile (like you did) does not make sense at all. A Dockerfile creates an offline image and in an image you don't want to start Eclipse ... you want to start Eclipse when a container is started from the image at runtime, right? So start it when the container is running on your netPI using the console.
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#5
Hello Sir,
I followed the procedure suggested by you..
Here is what i did
1) Connected HDMI monitor, Mouse, Keyboard to Net Pi and the HDMI container is set to restart on startup.
2) Powered on the Netpi
3) Then using the terminal on HDMI screen, entered the commands for downloading eclipse "apt get install eclipse"
4) Eclipse got installed successfully
5) Then entered the command "eclipse" in the terminal. Opened the GUI and it was working as intended.

I didnot try these commands yet in a Dockerfile and will let you know once i do that.

Meanwhile, I need few clarifications.

1) As we downloaded eclipse from the terminal but not using docker image, Is the eclipse application which is run by following above procedure running through docker or it is running outside docker?
2) In my application I have a java file which has to access an external file using a http request. All my java application written on eclipse running on Netpi worked well except that the http request could not be made.
3) I tried making a http request from the chromium browser in Netpi. It worked well.
4) Also tried running the same program in eclipse on RPi3. The http request was made successfully from the Java application it self.

I want to know whether this problem is due to the fact that we are running eclipse out of docker or is there any other piece I am missing.

By the way, I would like to thank you for your elaborate response which helps a beginner like me to understand things better..

Thanks again
Rahul
  Reply
#6
1.) Yes Rahul the whole Desktop is running encapsulated in a container ... and yes also the console you are opening via terminal on HDMI screen is running inside the container. (So if you would remove the whole container from your system via Docker Web GUI, then everything is gone)
2.) Whether an application is running inside a container or outside a container as on your RPi3 should be always result in the same behaviour. I have no explanation right now why it isn't running. Your http request is a service you initiate from inside the container so there is no filter at all for outgoing TCP/IP packets and also responses to this packet.
3.) ok
4.) ok

What you can also test from the Desktop console are simple things like "ping" command first, to see if you reach the http server's IP address.
As next you can continue to use "curl" command as described here with an example: https://askubuntu.com/questions/299870/h...l-in-linux in your console.
You need to set up the parameters of course accordingly to your http service needed. I am pretty sure that it will work.
This is just to test and to prove that in no way a container restricts applications needed outgoing connection.

A different thing is of course incoming connections if http requests come from outside netPI and shall land in a container. For such scenarios container ports need to be opened at container start time. But as far as I have understood this is not what you want.

I am sorry to say that I am not familiar with eclipse and java and your application. The only thing I can tell your there is no limitation in a container. There must be another reason why the http request does not go out. Maybe eclipse is a differnet version compared to the one on Rpi3.

Usually you get error codes back on http requests. What is the error code? Is there anything you can search on the internet if others have the same problem?
You never fail until you stop trying.“, Albert Einstein (1879 - 1955)

  Reply
#7
(January-19th-2019, 08:33 PM)Armin@netPI Wrote: 1.) Yes Rahul the whole Desktop is running encapsulated in a container ... and yes also the console you are opening via terminal on HDMI screen is running inside the container. (So if you would remove the whole container from your system via Docker Web GUI, then everything is gone)
2.) Whether an application is running inside a container or outside a container as on your RPi3 should be always result in the same behaviour. I have no explanation right now why it isn't running. Your http request is a service you initiate from inside the container so there is no filter at all for outgoing TCP/IP packets and also responses to this packet.
3.) ok
4.) ok

What you can also test from the Desktop console are simple things like "ping" command first, to see if you reach the http server's IP address.
As next you can continue to use "curl" command as described here with an example: https://askubuntu.com/questions/299870/h...l-in-linux in your console.
You need to set up the parameters of course accordingly to your http service needed. I am pretty sure that it will work.
This is just to test and to prove that in no way a container restricts applications needed outgoing connection.

A different thing is of course incoming connections if http requests come from outside netPI and shall land in a container. For such scenarios container ports need to be opened at container start time. But as far as I have understood this is not what you want.

I am sorry to say that I am not familiar with eclipse and java and your application. The only thing I can tell your there is no limitation in a container. There must be another reason why the http request does not go out. Maybe eclipse is a differnet version compared to the one on Rpi3.

Usually you get error codes back on http requests. What is the error code? Is there anything you can search on the internet if others have the same problem?

Hello Sir,

I will try further based on your inputs .. Thank You
  Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
Information netPI Docker REST API for versions >= V1.1.4.0 Patrick@netPI 1 59 July-16th-2019, 02:45 PM
Last Post: Patrick@netPI
  [SOLVED] Pull Docker Image a.w.d.m. 8 34 July-8th-2019, 11:17 AM
Last Post: Armin@netPI
  [SOLVED] Docker issues AlexRegev 7 191 June-26th-2019, 02:14 PM
Last Post: AlexRegev
  docker timing MGharat 2 34 June-13th-2019, 08:57 AM
Last Post: Patrick@netPI
  Launching multi-containers at a time - Docker stacks Armin@netPI 0 21 June-4th-2019, 04:11 PM
Last Post: Armin@netPI
  [INFO]Docker DNS server Armin@netPI 0 19 March-7th-2019, 09:02 AM
Last Post: Armin@netPI
  [SOLVED] node-red Dashboard Docker Image for netPI? anrodriguez 1 23 February-7th-2019, 05:35 PM
Last Post: Armin@netPI
  Setup trusted Docker registry on a Raspberry Pi to host netPI containers Armin@netPI 12 637 January-31st-2019, 06:47 PM
Last Post: Armin@netPI
  [SOLVED] Keep getting a message that session expired in Docker SteveO 2 41 January-24th-2019, 11:50 AM
Last Post: Armin@netPI
  [INFO] RESTful API for Docker remote control Armin@netPI 0 90 December-17th-2018, 10:15 AM
Last Post: Armin@netPI

Forum Jump:


Users browsing this thread: 1 Guest(s)