How to run a X Windows application in Codenvy Cloud IDE? - codenvy

Copdenvy's shellinabox runner allows you to start a shell in the browser in which you can compile and run your code. This is fine for applications that are console based. Is it possible to run an X Windows application in the cloud and see the graphical window?
Setting the DISPLAY variable in the shell to that of your Linux workstation could work, though it relies on you being in control of the local network for things like NAT and firewall settings. The attraction of the cloud IDE is that you only need a browser and an https connection.
Can you ssh -X into the Docker container from an X capable source? Where would you find the URL? How would you manage the ssh keys?

If you look at the Java/Swing "VNC + Java 7" runner for example you'll see that you're able to run an application which is using X DISPLAY through VNC. Codenvy supplies a web based X Windows environment that you can access by clicking on the hyperlink that is shown underneath the Console window, to the left of the Timeout counter. You can then look at the Docker recipe used to start this sample.
SSH in the docker container could be managed in Codenvy 3.x if you install inside the VM the sshd daemon and export the ssh/22 port. In upcoming Codenvy SaaS 4.x ssh will be enabled without any configuration.

Related

How to Run Docker Linux Containers on Windows Server 2016 Build 14393

I'm in a situation where:
I have no choice of server OS (Windows Server 2016 Build 14393).
And no choice of container OS (I need Linux Containers).
And I don't need Docker EE (Enterprise), CE (Desktop Edition) will do.
The easiest way to get Linux containers without hacky workarounds is to download Docker Community Edition 2.0.0.3 2019-02-15
Link: https://download.docker.com/win/stable/31259/Docker%20for%20Windows%20Installer.exe
Page with all versions: https://docs.docker.com/docker-for-windows/release-notes/
Simply download/copy the file to the Windows Server 2016 machine and run it.
It can also run offline for air gapped systems.
Uncheck the "Use Windows containers" during setup. Unchecked by default.
You will get a message after installing saying that windows so and so is deprecated. Click OK.
Log out and log back in.
If you hadn't installed Hyper-V it'll prompt you to do it automatically. Allow it, let it finish and restart. You're good to go now.
I've tested this by running several Linux containers, it works fine. If I'm missing something do share for the benefit of others. The downside is you cannot update to a later version of Docker.
Update:
Disclaimers:
This can help you avoid the hardware limitations and complexities of using LCOW with Docker-EE for Windows.
It is more recent than the latest official version of LCOW available.
This won't let you run Windows and Linux containers in parallel. You can only run one or the other.
This also won't start docker automatically at startup (not until you login). To start docker without login you'll need to add Docker Desktop Executable to Windows Task Scheduler and configure it to run on startup whether user is logged in or not. You'll have to provide an account for it (ideally a service account, or an account with a permanent password)

Cannot launch GUI program on Docker container on remote server

My working machine in the office is Ubuntu 18.04, and I have installed a Docker container in this machine. Everything works fine, and I can use Graphic User Interface (GUI) programs such as Firefox and PyCharm in the Docker container. When I works at home, I use my Windows 10 notebook, and in order to connect my working machine in the office, I use X2Go program. With this program, I can remotely connect the machine in my office with GUI. I can also run GUI programs remotely. However, when installed Docker container once again remotely, I cannot use GUI programs in the Docker container. The reason is because in order to let the Docker container access host machine's GUI, I use xhost + command. However, when running this command remotely, I received the following error:
# xhost: must be on local machine to enable or disable access control.
If I ignore this error message, I cannot launch any GUI programs on the Docker container. Any ideas? Thanks.
This article may help:
https://www.ibm.com/support/pages/remote-install-websphere-application-server-unix-host
In the article:
If the remote host is not authorized to connect, you can add it to the
list of authorized clients using the following command:
xhost +
xhost: must be on local machine to enable or disable access control.
This indicates that this command is only authorized from a local
console (For example, not within a telnet session).
Next, you must export the display so that GUI screens generated on the
remote host will be displayed on the local host. To do this, run the
following command on the remote host while logged in through the
telnet session from the local host:
export DISPLAY=
Also your Remote Desktop protocol could be an issue.
X2Go uses NX protocol with SSH for security.
NX protocol uses a caching technology which may be part of the the problem. Remote desktop technologies can vary the experience and may not work with docker GUI remotely.
I have had similar issues with remote desktop technologies (RDP, VNC etc) where some or all of the desktop experience is not visible.
I suggest to try a VNC (RFB protocol) software and see if that works. RDP is another solution.
Be aware VNC and RDP are not by default very secure unless you use a tunneling solution (VPN etc) and encryption. There are VNCs with built in encryption (via SSH) and RDP has security solutions also, but if you are accessing it from home to work you should make sure your security manager is aware of the technology you choose that works for you.

GUI in docker application

I have a desktop application written completely in C with GUI written in Gtk. Currently, it works fine on my Ubuntu desktop.
Now, I want to use the application independent of the OS. Therefore, Docker seems to help with it but as far as I know, it only provides web based UI.
How can I use Docker to deploy standalone desktop applications?
Is there any other container which does the job?
P.S.: The application is written in Gtk 2 hence I cannot use broadway.
I haven't done it myself anytime but just suggesting what might seem obvious.
You can try this though:
Run XVNC server inside the container
Expose the port at which XVNC runs
Connect to the XVNC server from the host machine
Trigger your gui application from within the XVNC console

Linux Docker container on Windows Server 2016

What is the way to run Linux docker container on Windows Server 2016? With Docker for Windows it easy to do in Windows 10. Is the only way to install Docker Toolbox and ignore the build-in containers feature all together?
It is possible to use Linux containers on W2016. It's a bit hacky though. User "Algore" described it here but I've copied it into this answer, of course.
Download "Docker for Windows": https://docs.docker.com/docker-for-windows/
Install "Docker for Windows" on Windows 10 Pro.
Copy C:\Program Files\Docker from the Windows 10 machine to C:\Program Files on your Server 2016 box.
On the W2016 box run install-windowsfeature hyper-v,containers
Copy these registry entries to a file and import them on your Server 2016 box (reg import):
---START---
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Docker Inc.]
[HKEY_LOCAL_MACHINE\SOFTWARE\Docker Inc.\Docker]
[HKEY_LOCAL_MACHINE\SOFTWARE\Docker Inc.\Docker\1.0]
"AppPath"="\"C:\Program Files\Docker\Docker\Docker for Windows.exe\""
"BinPath"="\"C:\Program Files\Docker\Docker\resources\bin\""
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\DockerService]
"EventMessageFile"=hex(2):43,00,3a,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,\
00,73,00,5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,2e,00,\
4e,00,45,00,54,00,5c,00,46,00,72,00,61,00,6d,00,65,00,77,00,6f,00,72,00,6b,\
00,36,00,34,00,5c,00,76,00,34,00,2e,00,30,00,2e,00,33,00,30,00,33,00,31,00,\
39,00,5c,00,45,00,76,00,65,00,6e,00,74,00,4c,00,6f,00,67,00,4d,00,65,00,73,\
00,73,00,61,00,67,00,65,00,73,00,2e,00,64,00,6c,00,6c,00,00,00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\com.docker.service]
"Type"=dword:00000010
"Start"=dword:00000002
"ErrorControl"=dword:00000000
"ImagePath"=hex(2):22,00,43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,\
6d,00,20,00,46,00,69,00,6c,00,65,00,73,00,5c,00,44,00,6f,00,63,00,6b,00,65,\
00,72,00,5c,00,44,00,6f,00,63,00,6b,00,65,00,72,00,5c,00,63,00,6f,00,6d,00,\
2e,00,64,00,6f,00,63,00,6b,00,65,00,72,00,2e,00,73,00,65,00,72,00,76,00,69,\
00,63,00,65,00,22,00,00,00
"DisplayName"="Docker for Windows Service"
"ObjectName"="LocalSystem"
"Description"="Run Docker for Windows backend service"
---END---
You can add an entry to currentversion\run or a scheduled job if you want docker for windows.exe to start up automatically.
Restart the computer and run the PowerShell script C:\Program Files\Docker\Docker\Resources\mobylinuxvm.ps1 -Create
Look into this ps1 file and notice that you can set various options. Please refer to these websites:
https://docker-saigon.github.io/post/Docker-Beta/
https://jpetazzo.github.io/2013/10/16/configure-docker-bridge-network/
Make sure the docker service com.docker.service (start-service com.docker.service) is running before you start C:\Program Files\Docker\Docker for Windows.exe
If you are running on server core and don't have the tray icon, click "change privacy settings" when the notification comes up after it starts to get to settings (or modify the json in programdata)
If you run into issues when trying things and rebuilding, check out the C:\Program Files\Docker\Docker\Resources\forceremovedocker.ps1 file for locations to delete settings such as in C:\programdata. I would advise against running the script as it deletes all docker related things. Just use pieces of it.
According to this from Stefan Scherer it is possible to run Linux containers on Server 2016. The instructions are:
Create a Linux Docker machine in Hyper-V
If you want to try out multi architecture you also use docker-machine
to create a Linux Docker Engine running in Hyper-V. I have prepared a
script that will set up everything as there are some known issues.
C:\vagrant\scripts\create-hyperv-linux-docker-machine.ps1
This PowerShell script creates a Docker machine and updates Docker
Engine to the latest so that the Windows Docker client is able to
communicate with the Linux Docker Engine.
Use the Linux Docker machine
Open a PowerShell terminal as an administrator and select the Linux
Docker machine with
docker-machine env --shell powershell | iex
Now run your first busybox container with
docker run -it busybox uname -a
Unfortunately, right now it is not possible to easily install the "Docker for Windows" tool. This installer provides a thin VM called MobyLinux which allows running of Linux containers on Windows Server 2016. You can find a hacky install attempt (which I have not tried) on the Docker forums.
For reference there is a good discussion about what is going on behind the scenes with "Docker for Windows".
The below worked on Windows Server 2016 build 14393.693 (January 2017) without hacky workarounds.
It may work on higher/lower builds but I tried to replicate on a recently updated version of Windows Server 2016 and it failed spectacularly! Feels like this hole had to be patched!
Download Docker Community Edition 2.0.0.3 2019-02-15
Link: https://download.docker.com/win/stable/31259/Docker%20for%20Windows%20Installer.exe
Page with all versions: https://docs.docker.com/docker-for-windows/release-notes/
Simply download/copy the file to the Windows Server 2016 machine and run it.
It can also run offline for air-gapped systems.
Uncheck the "Use Windows containers" during setup. Unchecked by default.
You will get a message after installing saying that windows so and so is deprecated. Click OK. enter image description here
Log out and log back in.
If you hadn't installed Hyper-V it'll prompt you to do it automatically. Allow it, let it finish and restart. You're good to go now. You may need to restart again if it fails to switch to Linux.
I've tested this by running several Linux containers, it works fine. If I'm missing something do share for the benefit of others. The downside is you cannot update to a later version of Docker.
Simply download and install Docker on Windows Server 2016 https://www.docker.com/docker-windows
If you run Windows Server 2016 as a VM using Hyper-V make sure to check this MS doc https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/nested-virtualization

Is it possible to run docker client in window server as done in Windows 7?

Presently is it possible to run docker client in Window Server2008 or 2012
in similar line as done in Windows 7 and 8 ?
I know they have been working on window container as well hyper V container which is supposed to release in next version in 2016. but is there any way to use docker client in it directly presently ?
Yes, if you can install VirtualBox on that Windows server, you can run the docker client (through boot2docker and its Tiny Core OS).
Since Windows Server 2008 is supported as a host server, the installation of boot2docker should be possible.
See also How to get Docker to run on a Windows System behind a corporate firewall?.

Resources