├── Dockerfile ├── LICENSE ├── README.md ├── build ├── eclipse └── run /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | MAINTAINER Fabio Rehm "fgrehm@gmail.com" 3 | 4 | RUN sed 's/main$/main universe/' -i /etc/apt/sources.list && \ 5 | apt-get update && apt-get install -y software-properties-common && \ 6 | add-apt-repository ppa:webupd8team/java -y && \ 7 | apt-get update && \ 8 | echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \ 9 | apt-get install -y oracle-java8-installer libxext-dev libxrender-dev libxtst-dev && \ 10 | apt-get clean && \ 11 | rm -rf /var/lib/apt/lists/* && \ 12 | rm -rf /tmp/* 13 | 14 | # Install libgtk as a separate step so that we can share the layer above with 15 | # the netbeans image 16 | RUN apt-get update && apt-get install -y libgtk2.0-0 libcanberra-gtk-module 17 | 18 | RUN wget http://eclipse.c3sl.ufpr.br/technology/epp/downloads/release/luna/SR1/eclipse-java-luna-SR1-linux-gtk-x86_64.tar.gz -O /tmp/eclipse.tar.gz -q && \ 19 | echo 'Installing eclipse' && \ 20 | tar -xf /tmp/eclipse.tar.gz -C /opt && \ 21 | rm /tmp/eclipse.tar.gz 22 | 23 | ADD run /usr/local/bin/eclipse 24 | 25 | RUN chmod +x /usr/local/bin/eclipse && \ 26 | mkdir -p /home/developer && \ 27 | echo "developer:x:1000:1000:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \ 28 | echo "developer:x:1000:" >> /etc/group && \ 29 | echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \ 30 | chmod 0440 /etc/sudoers.d/developer && \ 31 | chown developer:developer -R /home/developer && \ 32 | chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo 33 | 34 | USER developer 35 | ENV HOME /home/developer 36 | WORKDIR /home/developer 37 | CMD /usr/local/bin/eclipse 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Fabio Rehm 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-eclipse 2 | 3 | Eclipse v4.4.1 in a Docker container 4 | 5 | ## Requirements 6 | 7 | * Docker 1.2+ (should work fine on 1.0+ but I haven't tried) 8 | * An X11 socket 9 | 10 | ## Quickstart 11 | 12 | Assuming `$HOME/bin` is on your `PATH` and that you are able to run `docker` 13 | commands [without `sudo`](http://docs.docker.io/installation/ubuntulinux/#giving-non-root-access), 14 | you can use the [provided `eclipse` script](eclipse) to start a disposable 15 | Eclipse Docker container with your project sources mounted at `/home/developer/workspace` 16 | within the container: 17 | 18 | ```sh 19 | # The image size is currently 1.131 GB, so go grab a coffee while Docker downloads it 20 | docker pull fgrehm/eclipse:v4.4.1 21 | L=$HOME/bin/eclipse && curl -sL https://github.com/fgrehm/docker-eclipse/raw/master/eclipse > $L && chmod +x $L 22 | cd /path/to/java/project 23 | eclipse 24 | ``` 25 | 26 | Once you close Eclipse the container will be removed and no traces of it will be 27 | kept on your machine (apart from the Docker image of course). 28 | 29 | ## Making plugins persist between sessions 30 | 31 | Eclipse plugins are kept on `$HOME/.eclipse` inside the container, so if you 32 | want to keep them around after you close it, you'll need to share it with your 33 | host. 34 | 35 | For example: 36 | 37 | ```sh 38 | mkdir -p .eclipse-docker 39 | docker run -ti --rm \ 40 | -e DISPLAY=$DISPLAY \ 41 | -v /tmp/.X11-unix:/tmp/.X11-unix \ 42 | -v `pwd`/.eclipse-docker:/home/developer \ 43 | -v `pwd`:/workspace \ 44 | fgrehm/eclipse:v4.4.1 45 | ``` 46 | 47 | ## Help! I started the container but I don't see the Eclipse screen 48 | 49 | You might have an issue with the X11 socket permissions since the default user 50 | used by the base image has an user and group ids set to `1000`, in that case 51 | you can run either create your own base image with the appropriate ids or run 52 | `xhost +` on your machine and try again. 53 | -------------------------------------------------------------------------------- /build: -------------------------------------------------------------------------------- 1 | echo 'This will take a lot of time...' 2 | docker build -t fgrehm/eclipse:v4.4.1 . 3 | -------------------------------------------------------------------------------- /eclipse: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker run -ti --rm \ 4 | -e DISPLAY=$DISPLAY \ 5 | -v /tmp/.X11-unix:/tmp/.X11-unix \ 6 | -v "`pwd`":/workspace \ 7 | fgrehm/eclipse:v4.4.1 8 | -------------------------------------------------------------------------------- /run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Make sure the user data directory is owned by the developer user 4 | if [ -d /home/developer/.eclipse ]; then 5 | sudo chown developer:developer /home/developer/.eclipse 6 | fi 7 | exec /opt/eclipse/eclipse 8 | --------------------------------------------------------------------------------