Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing argument to docker image #170

Closed
freewind opened this issue Jan 9, 2016 · 8 comments
Closed

Passing argument to docker image #170

freewind opened this issue Jan 9, 2016 · 8 comments
Labels
kind/question Questions that haven't been identified as being feature requests or bugs.

Comments

@freewind
Copy link

freewind commented Jan 9, 2016

Latest docker image can start, but I hope I can pass some argument to the internal che.sh, like:

docker run --privileged -it --name che --net=host codenvy/che:nightly -r:111.111.111.111

I've tried but make it myself, but not successful. So I asked a question on stackoverflow: http://stackoverflow.com/questions/34691752/how-to-write-a-dockerfile-which-i-can-start-a-service-and-run-a-shell-and-also-a

Thanks for help

@garagatyi
Copy link

Have you tried

RUN sudo chown -R user:user /home/user/che && \
     sudo service docker start
ENTRYPOINT ["/bin/sh", "-c", "/home/user/che/bin/che.sh run"]

And then

docker run -it --priviledged my/che -r:111.111.111.111

@freewind
Copy link
Author

freewind commented Jan 9, 2016

@garagatyi Thanks ~

I have tried but it will report this error:

!!! Running 'docker' succeeded, but 'docker ps' failed. This usually means that docker cannot reach its daemon.

Looks like something went wrong. Possible issues:
  1. (Win | Mac) VirtualBox not installed          ==> Rerun Docker Toolbox installation
  2. (Win | Mac) Docker Machine not installed      ==> Rerun Docker Toolbox installation
  3. (Win | Mac) Docker is not reachable           ==> Docker VM failed to start
  4. (Win | Mac) Docker ok, but docker ps fails    ==> Docker environment variables not set properly
  5. (Linux) Docker is not reachable               ==> Install: wget -qO- https://get.docker.com/ | sh
  6. Could not find the Che app server             ==> Did /tomcat get moved away from CHE_HOME?
  7. Did you use the right parameter syntax?       ==> See usage

We have seen issues with VirtualBox on windows where your VM gets corrupted when your computer is suspended while the VM is still running. This will appear as SSH or ethernet connection issues. This is rare, but if encountered, current known solution is to uninstall VirtualBox and Docker Toolbox, and then reinstall.

Che Environment Variables:
  (REQUIRED) JAVA_HOME                             ==> Location of Java runtime
  (REQUIRED: WIN|MAC) DOCKER_TOOLBOX_INSTALL_PATH  ==> Location of Docker Toolbox
  (REQUIRED: WIN|MAC) VBOX_MSI_INSTALL_PATH        ==> Location of VirtualBox
  (OPTIONAL) CHE_HOME                              ==> Directory where Che is installed
  (OPTIONAL) CHE_LOCAL_CONF_DIR                    ==> Directory with custom Che .properties files
  (OPTIONAL) CHE_LOGS_DIR                          ==> Directory for Che output logs


Usage:
  che [-i] [-i:tag] [-p:port] [-r:ip] [-m:vm] [-d] [run | start | stop]

     -i,      --image        Launches Che within a Docker container using latest image
     -i:tag,  --image:tag    Launches Che within a Docker container using specific image tag
     -p:port, --port:port    Port that Che server will use for HTTP requests; default=8080
     -r:ip,   --remote:ip    If Che clients are not localhost, set to IP address of Che server
     -m:vm,   --machine:vm   For Win & Mac, sets the docker-machine VM name to vm; default=default
     -s,      --suppress     Do not print browser client connection information
     -h,      --help         Show this help
     -d,      --debug        Use debug mode (prints command line options + app server debug)
     run                     Starts Che application server in current console
     start                   Starts Che application server in new console
     stop                    Stops Che application server

The -r flag sets the DOCKER_MACHINE_HOST system environment variable. Set this to the IP address of the node
that is running your Docker daemon. Only necessary to set this if on Linux and your browser clients are not
localhost, ie they are remote. This property automatically set for Che on Windows and Mac

Looks like the internal docker is not starting well which che.sh is running

@TylerJewell
Copy link

Hi: You wrote on stack overflow:

My final solution is following you last "simple" case, neither write ENTRYPOINT nor CMD, just RUN sudo chown -R user:user /home/user/che, and invoke it like this: docker run -it --rm --privileged --net=host my/che bash -c " sudo service docker start && cd /home/user/che/bin/ && ./che.sh -r:159.203.211.163 run", which is working as I expected, although looks a little ugly.

Trying to learn some lessons here. Should we make any improvements to:

  1. The way the Dockerfile is authored, or:
  2. The way we launch Docker instances from within the che.sh scripts?

@freewind
Copy link
Author

@TylerJewell Thanks for your kind suggestions! I'm not sure what I really want for now, since I haven't read much of the che code, and not quite clear about the design in the che.sh.

I'm start to read che code now, may I reply this several days later?

@ddementieva ddementieva added the kind/question Questions that haven't been identified as being feature requests or bugs. label Jan 21, 2016
@amalic
Copy link

amalic commented Jan 28, 2016

I have the same problem on WIndows7 (64Bit) at my workplace-PC and on WIndows10 at home.

If you guys are testing the installation, maybe you're testing it on a machine which already fulfills a prerequisite which the installation of che doesn't create.

`

echo %JAVA_HOME%
C:\Development\Java\jdk1.8.0_60

echo %DOCKER_TOOLBOX_INSTALL_PATH%
C:\Program Files\Docker Toolbox

echo %VBOX_MSI_INSTALL_PATH%
C:\Program Files\Oracle\VirtualBox
`

Following EInvironment variables are not set:
CHE_HOME, CHE_LOCAL_CONF_DIR, CHE_LOGS_DIR, CHE_DOCKER_MACHINE_NAME, DOCKER_MACHINE_HOST

@randywallace
Copy link

@freewind if you still have problems try a different storage on docker. I kept running into this issue (docker not starting in docker-in-docker scenario) until I used devicemapper in both my VM and the nested docker. I ended up creating a compose file to run eclipse-che for me (note that you will have to make some changes for the extra_hosts and the -r) which you can use to easily track how you override the CMD from the original image, without having to bake a new Dockerfile image just for running che.

che:
  image: codenvy/che:latest
  #image: codenvy/che:4.0.0-beta-13
  command: >
    /bin/bash -c "
    sudo chown -R user:user /home/user/che &&
    sudo chmod 666 /etc/default/docker &&
    echo 'DOCKER_OPTS="'"'"-s devicemapper"'"'"' >> /etc/default/docker &&
    sudo service docker start &&
    cd /home/user/che/bin/ && ./che.sh run -d -r:${DOCKER_MACHINE_HOST}
    "
  ports:
    - "8080:8080"
    - "32768-32788:32768-32788"
  volumes:
    - "${HOME}/.che/conf:/home/user/.che"
    - "${HOME}/.che/projects:/home/user/che/temp/fs-root"
  privileged: true
  container_name: che
  extra_hosts:
    - "${CHE_HOSTNAME_IN_BROWSER}:127.0.0.1"

and I run it with: CHE_HOSTNAME_IN_BROWSER="vagrant-docker" DOCKER_MACHINE_HOST="172.128.128.3" docker-compose -f this_file.yaml up -d

hope this helps... YMMV (a lot), I run this on a Vagrant box in OS X, not via docker-machine

@TylerJewell
Copy link

Pull request #257 will help with some of the questions stated here. Can you check this and let us know if we can close this issue?

@ghost
Copy link

ghost commented Feb 21, 2016

@freewind The new way to start Che in Docker addresses all these issues. Docs are here https://eclipse-che.readme.io/docs/usage-docker

In other threads you confirmed you can run Che in Docker on Digital Ocean. So I am closing the issue. Feel free ti reopen if the problem persists.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Questions that haven't been identified as being feature requests or bugs.
Projects
None yet
Development

No branches or pull requests

6 participants