Che: Share (Project) files between two machines in workspace

Created on 13 Jul 2017  路  7Comments  路  Source: eclipse/che

I'd like to easily share files between different machines in workspace. basically i want the /project files available on all machines - is there a best practice for that?
I started with a workspace recipe looks like that

services:
  dev-machine:
    image: my-dtr.de/cloudia/6i-sdk
  rt-machine:
    image: my-dtr.de/cloudia/6i-runtime

On the dev-machine is the compiler, and my command triggers the make. The result of the build (executables) are lying on the same dev-machine. But they should be executed on runtime-machine. So i kind of need to copy and launch it there.

  • I tried with CHE_WORKSPACE_VOLUME=/chetmp:/chetmp in the che.env file, but this created a shared volume /chetmp _only available_ on the dev-machine - not available on the rt-machine
  • additionally i started to extend the recipe/compose file with the two machines by using volumes_from like this:
services:
  dev-machine:
    image: my-dtr.de/cloudia/6i-sdk
  rt-machine:
    image: my-dtr.de/cloudia/6i-runtime
    depends_on:
      - dev-machine
    links:
      - dev-machine
    volumes_from:
      - dev-machine

but in the rt-machine-terminal I could not see the /chetmp folder that i expected would be shared.
adding a volume to the compose file:

services:
  dev-machine:
    image: my-dtr.de/cloudia/6i-sdk
    volumes:
      - /chetmp2:/chetmp2
  ...

does throw an Error on saying:

Volumes binding is forbidden but found in machine 'dev-machine' of environment 'default'

How can i access the files from dev-machine:/projects/my-project/ from the rt-machine?

OS and version:
Ubuntu 16.04.
docker 17.06.0-ce
che 5.14

Diagnostics:

docker run -ti --rm -v /var/run/docker.sock:/var/run/docker.sock -v /home/sg82fe/che/5.14/:/data eclipse/che:5.14.0 info
WARNING: No swap limit support
INFO: Proxy: HTTP_PROXY=http://172.17.0.1:3128/, HTTPS_PROXY=http://172.17.0.1:3128/, NO_PROXY=172.17.0.1,localhost,127.0.0.1
INFO: (che cli): 5.14.0 - using docker 17.06.0-ce / native

CLI:
 TTY:            true
 Daemon:         /var/run/docker.sock
 Image:          eclipse/che:5.14.0
 Version:        5.14.0
 Command:        info
 Parameters:     info
Mounts:
 /data:          /home/sg82fe/che/5.14/
 /data/instance: not set
 /data/backup:   not set
 /repo:          not set
 /assembly:      not set
 /sync:          not set
 /unison:        not set
 /chedir:        not set
System:
 Docker:         native
 Proxy:          HTTP_PROXY=http://172.17.0.1:3128/, HTTPS_PROXY=http://172.17.0.1:3128/, NO_PROXY=172.17.0.1,localhost,127.0.0.1
Internal:
 CHE_VERSION:    5.14.0
 CHE_HOST:       10.61.186.132
 CHE_INSTANCE:   /home/sg82fe/che/5.14//instance
 CHE_CONFIG:     /home/sg82fe/che/5.14/
 CHE_BACKUP:     /home/sg82fe/che/5.14//backup
 CHE_REGISTRY:   /version
 CHE_DEBUG:      false
 IP Detection:   10.61.186.132
 Initialized:    true
Image Registry:
 IMAGE_INIT=eclipse/che-init:5.14.0
 IMAGE_CHE=eclipse/che-server:5.14.0
 IMAGE_COMPOSE=docker/compose:1.8.1
 IMAGE_TRAEFIK=traefik:v1.3.0-rc3
 BOOTSTRAP_IMAGE_ALPINE=alpine:3.4
 BOOTSTRAP_IMAGE_CHEIP=eclipse/che-ip:5.14.0
 UTILITY_IMAGE_CHEACTION=eclipse/che-action:5.14.0
 UTILITY_IMAGE_CHEDIR=eclipse/che-dir:5.14.0
 UTILITY_IMAGE_CHETEST=eclipse/che-test:5.14.0
 UTILITY_IMAGE_CHEMOUNT=eclipse/che-mount:5.14.0
che.env:
 CHE_HOST=10.61.186.132
 CHE_HTTP_PROXY=http://172.17.0.1:3128/
 CHE_HTTPS_PROXY=http://172.17.0.1:3128/
 CHE_NO_PROXY=172.17.0.1,localhost,127.0.0.1,10.61.186.132
 CHE_WORKSPACE_HTTP__PROXY=http://172.17.0.1:3128/
 CHE_WORKSPACE_HTTPS__PROXY=http://172.17.0.1:3128/
 CHE_WORKSPACE_NO__PROXY=che-host,172.17.0.1,localhost,127.0.0.1,10.61.186.132
 CHE_WORKSPACE_VOLUME=/chetmp:/chetmp
 CHE_SINGLE_PORT=false

kinquestion

Most helpful comment

@sg82fe Here's my composefile that worked as expected:

services:
  dev-machine:
    image: eclipse/ubuntu_jdk8
  nginx:
    image: nginx
    depends_on:
      - dev-machine
    volumes_from:
      - dev-machine

Two machines are started, and in nginx machine I can see projects dir:

image

image

All 7 comments

@sg82fe Here's my composefile that worked as expected:

services:
  dev-machine:
    image: eclipse/ubuntu_jdk8
  nginx:
    image: nginx
    depends_on:
      - dev-machine
    volumes_from:
      - dev-machine

Two machines are started, and in nginx machine I can see projects dir:

image

image

Thanks! yes, the common access from both machines to /projects is working in that way. fine :)
I think I was irritated because on the dev-machine I cannot create files in /projects - i must use sudo ... looking with portainer into the dev-machine it shows the volume in container as /projects:Z
Why is there a write protection on the dev-machine?

@sg82fe there's no write protection in /projects on dev-machine. When you say:

I cannot create files in /projects

Can you elaborate? Did you exec into container and try create file this way? Or did you use Che IDE terminal?

Can you also share output from ls -la on /projects?

After first launching a new workspace with this stack / runtime / recipe:

services:
  dev-machine:
    image: rb-dtr.de.bosch.com/cloudia/6i
  rt-machine:
    image: rb-dtr.de.bosch.com/sg82fe/6i-core-runtime-from-tarball
    depends_on:
      - dev-machine
    volumes_from:
      - dev-machine

I did use two Che IDE terminals

  • terminal 1 on dev-machine
  • terminal 2 on rt-machine
    you can see the commands and flow on the screen-shot below

what i have done: Via eclipse che IDE terminals i used both terminals to navigate (cd) to /projects folder. initially /projects is empty (visible via ls -la on both terminals). Then on terminal 2 (rt-machine) I create a file via touch fil : file gets created and is visible in /projects in both terminals. Creating file via touch from terminal 1 (dev-machine) is refused with permission denied. using sudo touch file is working. The second created file (from dev-machine created) is visiible on rt-machine /projects folder via ls -la

unfortunately attaching screen-shot seems not to work here in my comment :-(

at least something noticable:
while on the rt-machine there is only the user _root_
on the dev-machine (eclipse/ubuntu_jre-based) there is a user _user_ and _root_.
by default on dev-machine, user is logged in in bash (in Eclipse Che terminal)
by default on rt-machine, root is logged in in bash (in Eclipse Che terminal)

Yes, it's because of different users. You may run chmod on /projects to set the right permissions.

Thank you for that hint - that works!
Although users are not in sync

  • on dev-machine always the (non-privileged) 'user' is logged in, and on the rt-machine there is only the 'root' available -
    The working solution for me is adding this to the dockerfiles for the two images of the two machines (SDK and Runtime)
...
USER root
RUN cd / && chmod 777 projects
...

I must correct the above technical tip - it does not solve - the access-rights of the projects volume are given from the host.
The solution that currently works for me is: adding _user_ to the rt-machine that only had a root so far, via Dockerfile

useradd -u1000 user 
USER user 
Was this page helpful?
0 / 5 - 0 ratings