├── .env ├── .gitignore ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── bin ├── auto-config-all.sh ├── auto-config-docker-compose.sh ├── auto-config-env.sh ├── auto-config-with-template.sh ├── create-venv.sh └── setup_venv_bash_profile.sh ├── build.sh ├── certificates ├── dummy.crt ├── openkbs-BA-NPE-CA-3.crt └── root.cert.pem ├── clean.sh ├── commit-push.sh ├── doc ├── KNIME-docker-IDE_v.3.7.0.png ├── KNIME-docker-compose-demo.flv └── KNIME-docker-run.sh-demo.flv ├── docker-compose.yml ├── logs.sh ├── restore.sh ├── run.sh ├── save.sh ├── shell.sh └── stop.sh /.env: -------------------------------------------------------------------------------- 1 | USER_ID=1000 2 | GROUP_ID=1000 3 | 4 | #### Rider configuration for run.sh #### 5 | # - Use "#VOLUMES" and "#PORTS" to indicate that the variables for run.sh" 6 | # - To ignore line, use "##" (double) in the beginning, e.g. "##VOLUMES" and "##PORTS" 7 | # - To indicate that the variables for run.sh", use only one "#", e.g. "#VOLUMES" and "#PORTS" 8 | #VOLUMES_LIST=".eclipse workspace" 9 | 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.ear 17 | *.zip 18 | *.tar.gz 19 | *.rar 20 | *.tgz 21 | *.tar 22 | 23 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 24 | hs_err_pid* 25 | 26 | .eclipse 27 | 28 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openkbs/jdk11-mvn-py3-x11 2 | 3 | MAINTAINER DrSnowbird "DrSnowbird@openkbs.org" 4 | 5 | ## ---- USER_NAME is defined in parent image: openkbs/jdk-mvn-py3-x11 already ---- 6 | ENV USER_NAME=${USER_NAME:-developer} 7 | ENV HOME=/home/${USER_NAME} 8 | 9 | ######################################################### 10 | #### ---- Build ARG and RUN ENV ---- 11 | ######################################################### 12 | ARG PRODUCT=${PRODUCT:-knime} 13 | ENV PRODUCT=knime 14 | ENV WORKSPACE=${HOME}/workspace 15 | 16 | ARG PRODUCT_VERSION=${PRODUCT_VERSION:-4.4.1} 17 | ENV PRODUCT_VERSION=${PRODUCT_VERSION} 18 | 19 | ARG PRODUCT_DIR=${PRODUCT_DIR:-knime_${PRODUCT_VERSION}} 20 | ENV PRODUCT_DIR=${PRODUCT_DIR} 21 | 22 | ARG PRODUCT_EXE=${PRODUCT_EXE:-knime} 23 | ENV PRODUCT_EXE=${PRODUCT_EXE} 24 | 25 | ARG INSTALL_BASE=${INSTALL_BASE:-/opt} 26 | ENV INSTALL_BASE=${INSTALL_BASE} 27 | 28 | #################################### 29 | #### ---- Install product: ---- #### 30 | #################################### 31 | ## --- Product Version specific --- 32 | # ENV DOWNLOAD_URL=https://download.knime.org/analytics-platform/linux/knime_4.2.2.linux.gtk.x86_64.tar.gz 33 | # ENV DOWNLOAD_URL=https://download.knime.org/analytics-platform/linux/knime-latest-linux.gtk.x86_64.tar.gz 34 | ENV DOWNLOAD_URL=https://download.knime.org/analytics-platform/linux/${PRODUCT}_${PRODUCT_VERSION}.linux.gtk.x86_64.tar.gz 35 | 36 | WORKDIR ${INSTALL_BASE} 37 | 38 | #### ---- Install for application ---- 39 | RUN sudo wget -q -c ${DOWNLOAD_URL} && \ 40 | sudo tar xvf $(basename ${DOWNLOAD_URL}) && \ 41 | sudo rm $(basename ${DOWNLOAD_URL} ) 42 | 43 | ######################################### 44 | #### ---- Addition Libs/Plugins ---- #### 45 | ######################################### 46 | ## -- hub.docker build having issue; temporarily remove these two lines -- 47 | #RUN sudo apt-get update -y && \ 48 | # sudo apt-get install -y libwebkitgtk-3.0-0 49 | 50 | VOLUME ${WORKSPACE} 51 | 52 | #### ---- Environment for running application ---- 53 | USER ${USER_NAME} 54 | 55 | ENV WORKSPACE=${HOME}/workspace 56 | 57 | USER ${USER_NAME} 58 | 59 | WORKDIR ${WORKSPACE} 60 | 61 | CMD "${INSTALL_BASE}/${PRODUCT_DIR}/${PRODUCT_EXE}" 62 | #CMD "firefox" 63 | 64 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2022 Ray Y. Sheu, Ph.D. 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------------------------------- 2 | # login first (Registry: e.g., hub.docker.io, registry.localhost:5000, etc.) 3 | # a.) docker login 4 | # or 5 | # b.) sudo docker login -p FpXM6Qy9vVL5kPeoefzxwA-oaYb-Wpej2iXTwV7UHYs -e unused -u unused docker-registry-default.openkbs.org 6 | # e.g. (using Openshift) 7 | # oc process -f ./files/deployments/template.yml -v API_NAME=$(REGISTRY_IMAGE) > template.active 8 | # 9 | # to run: 10 | # make [ APP_VERSION=<...> DOCKER_NAME=<...> REGISTRY_HOST=<...> ] 11 | # example: 12 | # make build 13 | # make up 14 | # make down 15 | # ------------------------------------------------------------------------------------------------------- 16 | 17 | SHELL := /bin/bash 18 | 19 | BASE_IMAGE := $(BASE_IMAGE) 20 | 21 | ## -- To Check syntax: 22 | # cat -e -t -v Makefile 23 | 24 | # The name of the container (default is current directory name) 25 | #DOCKER_NAME := $(shell echo $${PWD\#\#*/}) 26 | DOCKER_NAME := $(shell echo $${PWD\#\#*/}|tr '[:upper:]' '[:lower:]'|tr "/: " "_" ) 27 | 28 | ORGANIZATION=$(shell echo $${ORGANIZATION:-openkbs}) 29 | APP_VERSION=$(shell echo $${APP_VERSION:-latest}) 30 | imageTag=$(ORGANIZATION)/$(DOCKER_NAME) 31 | 32 | ## Docker Registry (Private Server) 33 | REGISTRY_HOST= 34 | #REGISTRY_HOST=$(shell echo $${REGISTRY_HOST:-localhost:5000}) 35 | REGISTRY_IMAGE=$(REGISTRY_HOST)/$(ORGANIZATION)/$(DOCKER_NAME) 36 | 37 | #VERSION?="$(APP_VERSION)-$$(date +%Y%m%d)" 38 | VERSION?="$(APP_VERSION)" 39 | 40 | ## -- Uncomment this to use local Registry Host -- 41 | DOCKER_IMAGE := $(ORGANIZATION)/$(DOCKER_NAME) 42 | 43 | ## -- To Check syntax: 44 | # cat -e -t -v Makefile 45 | 46 | # -- example -- 47 | #VOLUME_MAP := "-v $${PWD}/data:/home/developer/data -v $${PWD}/workspace:/home/developer/workspace" 48 | VOLUME_MAP := 49 | 50 | # -- Local SAVE of image -- 51 | IMAGE_EXPORT_PATH := "$${PWD}/archive" 52 | 53 | # { no, on-failure, unless-stopped, always } 54 | RESTART_OPTION := always 55 | 56 | SHA := $(shell git describe --match=NeVeRmAtCh --always --abbrev=40 --dirty=*) 57 | 58 | .PHONY: clean rmi build push pull up down run stop exec 59 | 60 | clean: 61 | echo $(DOCKER_NAME) $(DOCKER_IMAGE):$(VERSION) 62 | 63 | default: build 64 | 65 | build: 66 | sudo docker build \ 67 | --build-arg BASE_IMAGE="$(BASE_IMAGE)" \ 68 | --build-arg CIRCLE_SHA1="$(SHA)" \ 69 | --build-arg version=$(VERSION) \ 70 | --build-arg VCS_REF=`git rev-parse --short HEAD` \ 71 | --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ 72 | -t $(DOCKER_IMAGE):$(VERSION) . 73 | 74 | push: build 75 | sudo docker commit -m "$comment" ${containerID} ${imageTag}:$(VERSION) 76 | sudo docker push $(DOCKER_IMAGE):$(VERSION) 77 | 78 | docker tag $(imageTag):$(VERSION) $(REGISTRY_IMAGE):$(VERSION) 79 | #sudo docker tag $(imageTag):latest $(REGISTRY_IMAGE):latest 80 | docker push $(REGISTRY_IMAGE):$(VERSION) 81 | #sudo docker push $(REGISTRY_IMAGE):latest 82 | @if [ ! "$(IMAGE_EXPORT_PATH)" = "" ]; then \ 83 | mkdir -p $(IMAGE_EXPORT_PATH); \ 84 | sudo docker save $(REGISTRY_IMAGE):$(VERSION) | gzip > $(IMAGE_EXPORT_PATH)/$(DOCKER_NAME)_$(VERSION).tar.gz; \ 85 | fi 86 | pull: 87 | @if [ "$(REGISTRY_HOST)" = "" ]; then \ 88 | sudo docker pull $(DOCKER_IMAGE):$(VERSION) ; \ 89 | else \ 90 | sudo docker pull $(REGISTRY_IMAGE):$(VERSION) ; \ 91 | fi 92 | 93 | 94 | up: build 95 | sudo docker-compose up -d 96 | 97 | down: 98 | sudo docker-compose down 99 | 100 | run: 101 | sudo docker run --name=$(DOCKER_NAME) --restart=$(RESTART_OPTION) $(VOLUME_MAP) $(DOCKER_IMAGE):$(VERSION) 102 | 103 | stop: run 104 | sudo docker stop --name=$(DOCKER_NAME) 105 | 106 | status: 107 | sudo docker ps 108 | 109 | rmi: 110 | sudo docker rmi $$(docker images -f dangling=true -q) 111 | 112 | exec: up 113 | sudo docker-compose exec $(DOCKER_NAME) /bin/bash 114 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # KNIME (latest/4.4.1) + Java 11 (1.8.0) OpenJDK + Maven 3.6 + Python 3.6 + PIP3 20 + npm 7 + node 16 + Gradle 6 + X11 (Desktop) 2 | 3 | [![](https://images.microbadger.com/badges/image/openkbs/knime-docker.svg)](https://microbadger.com/images/openkbs/knime-docker "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/version/openkbs/knime-docker.svg)](https://microbadger.com/images/openkbs/knime-docker "Get your own version badge on microbadger.com") 4 | 5 | ## (See also) Web-Browser-based (VNC/NoVNC) KNIME Docker: 6 | * [KNIME over VNC/NoVNC (by openkbs/knime-vnc-docker) ](https://hub.docker.com/r/openkbs/knime-vnc-docker/): 7 | * Providing users to use KNIME on `any (literally)` HTML5 Web browser-capable computers, laptop, tablets, smartphone phones (iPhone etc.), or lab special devices/equipments with Web Browsers). 8 | * The KNIME-VNC-docker will be running remote in cloud cluster node. 9 | * You can deploy KNIME Studio over Openshift, Kubernetes, or any container cluster platforms. 10 | 11 | ## Join, Share, and Support the Community: 12 | * [KNIME Blogs](https://www.knime.com/blog) 13 | * [Join the Community at KNIME web site](https://www.knime.com/knime-community) 14 | 15 | # Components: 16 | * [KNIME Platform](https://www.knime.com/download-knime-analytics-platform-sdk) latest (v 4.3.2) for Machine Learning & Big Data Analytics 17 | * Ubuntu 18.04 LTS now as LTS Docker base image. 18 | * [Java openkbs/jdk-mvn-py3 - see README.md](https://github.com/DrSnowbird/jdk-mvn-py3/blob/master/README.md) 19 | * [Base Container Image: openkbs/jdk-mvn-py3](https://github.com/DrSnowbird/jdk-mvn-py3) 20 | * [Base Container Image: openkbs/jdk-mvn-py3-x11](https://github.com/DrSnowbird/jdk-mvn-py3-x11) 21 | * [Base Components: OpenJDK, Python 3, PIP, Node/NPM, Gradle, Maven, etc.](https://github.com/DrSnowbird/jdk-mvn-py3#components) 22 | 23 | # NOTICE: Due to docker.hub.io not allowing free hosting anymore, you have to make your local build including the parent images: 24 | - [DrSnowbird/jdk11-mvn-py3](https://github.com/DrSnowbird/jdk11-mvn-py3), [GIT](git@github.com:DrSnowbird/jdk11-mvn-py3.git) 25 | - [DrSnowbird/jdk11-mvn-py3-X11](https://github.com/DrSnowbird/jdk11-mvn-py3-X11), [GIT](git@github.com:DrSnowbird/jdk11-mvn-py3-X11.git) 26 | 27 | # Build 28 | You can build your own image locally. 29 | ``` 30 | ./build.sh 31 | ``` 32 | 33 | # Run (recommended for easy-start) 34 | Image is pulled from openksb/knime-docker 35 | ``` 36 | ./run.sh 37 | ``` 38 | ## Where are workspace and data? 39 | - The "./run.sh" will create and map the container's data and workspace directories to the host's directory as below (unless you change ./.env configuration). 40 | - You can copy source data or projects/workflow to these two directory and the KNIME Studio inside the container will have direct access to the files you just copy. 41 | 42 | ``` 43 | $HOME/data-docker/knime-docker 44 | ├── data 45 | └── workspace 46 | └── Example Workflows 47 | ├── Basic Examples 48 | ├── Customer Intelligence 49 | ├── Retail 50 | ├── Social Media 51 | ├── TheData 52 | └── workflowset.meta 53 | ``` 54 | 55 | And, "docker-compose" will use the current git project directory's "./workspace" to map the container's /home/developer/workspace: 56 | 57 | ``` 58 | ./.eclipse 59 | ./workspace 60 | ``` 61 | 62 | **Note: You can copy your KNIME workflow project in and out the workspaces and it is directly mapped into the container's /home/developer/workspace.** 63 | 64 | # References 65 | * [KNIME](https://www.knime.com) 66 | * [KNIME Learning Center](https://www.knime.com/resources) 67 | * [KNIME Analytics Platform](https://www.knime.com/download-knime-analytics-platform-sdk) 68 | * [KNIME FAQ](https://www.knime.com/faq#q6) 69 | 70 | # See also VNC/noVNC docker-based IDE or Analytics Platform 71 | * [consol/ubuntu-xfce-vnc](https://hub.docker.com/r/consol/ubuntu-xfce-vnc/) 72 | * [openkbs/eclipse-photon-vnc-docker](https://hub.docker.com/r/openkbs/eclipse-photon-vnc-docker/) 73 | * [openkbs/knime-vnc-docker](https://hub.docker.com/r/openkbs/knime-vnc-docker/) 74 | 75 | # See Also - docker-based IDE 76 | * [openkbs/atom-docker](https://hub.docker.com/r/openkbs/atom-docker/) 77 | * [openkbs/eclipse-oxygen-docker](https://hub.docker.com/r/openkbs/eclipse-oxygen-docker/) 78 | * [openkbs/eclipse-photon-docker](https://hub.docker.com/r/openkbs/eclipse-photon-docker/) 79 | * [openkbs/eclipse-photon-vnc-docker](https://hub.docker.com/r/openkbs/eclipse-photon-vnc-docker/) 80 | * [openkbs/intellj-docker](https://hub.docker.com/r/openkbs/intellij-docker/) 81 | * [openkbs/intellj-vnc-docker](https://hub.docker.com/r/openkbs/intellij-vnc-docker/) 82 | * [openkbs/knime-vnc-docker (VNC/NoVNC)](https://hub.docker.com/r/openkbs/knime-vnc-docker/) 83 | * [openkbs/knime-docker (X11/Desktop)](https://hub.docker.com/r/openkbs/knime-docker/) 84 | * [openkbs/netbeans10-docker](https://hub.docker.com/r/openkbs/netbeans10-docker/) 85 | * [openkbs/netbeans](https://hub.docker.com/r/openkbs/netbeans/) 86 | * [openkbs/papyrus-sysml-docker](https://hub.docker.com/r/openkbs/papyrus-sysml-docker/) 87 | * [openkbs/pycharm-docker](https://hub.docker.com/r/openkbs/pycharm-docker/) 88 | * [openkbs/rapidminer-docker](https://cloud.docker.com/u/openkbs/repository/docker/openkbs/rapidminer-docker) 89 | * [openkbs/scala-ide-docker](https://hub.docker.com/r/openkbs/scala-ide-docker/) 90 | * [openkbs/sublime-docker](https://hub.docker.com/r/openkbs/sublime-docker/) 91 | * [openkbs/webstorm-docker](https://hub.docker.com/r/openkbs/webstorm-docker/) 92 | * [openkbs/webstorm-vnc-docker](https://hub.docker.com/r/openkbs/webstorm-vnc-docker/) 93 | 94 | # Display X11 Issue 95 | More resource in X11 display of Eclipse on your host machine's OS, please see 96 | * [X11 Display problem](https://askubuntu.com/questions/871092/failed-to-connect-to-mir-failed-to-connect-to-server-socket-no-such-file-or-di) 97 | * [X11 Display with Xhost](http://www.ethicalhackx.com/fix-gtk-warning-cannot-open-display/) 98 | * You might see the warning message in the launching xterm console like below, you can just ignore it. I googles around and some blogs just suggested to ignore since the IDE still functional ok. 99 | 100 | # Releases information 101 | See [Release information](https://github.com/DrSnowbird/jdk-mvn-py3#releases-information) 102 | 103 | -------------------------------------------------------------------------------- /bin/auto-config-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ################################ Usage ####################################### 4 | 5 | ## ---------- ## 6 | ## -- main -- ## 7 | ## ---------- ## 8 | 9 | set -e 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 12 | 13 | PROJ_DIR=$(dirname $DIR) 14 | 15 | cd ${PROJ_DIR} 16 | 17 | bin/auto-config-with-template.sh $@ .env.template 18 | bin/auto-config-with-template.sh $@ docker-compose.yml.template 19 | 20 | -------------------------------------------------------------------------------- /bin/auto-config-docker-compose.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ################################ Usage ####################################### 4 | 5 | ## ---------- ## 6 | ## -- main -- ## 7 | ## ---------- ## 8 | 9 | set -e 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 12 | 13 | PROJ_DIR=$(dirname $DIR) 14 | 15 | cd ${PROJ_DIR} 16 | 17 | bin/auto-config-with-template.sh $@ docker-compose.yml.template 18 | 19 | -------------------------------------------------------------------------------- /bin/auto-config-env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ################################ Usage ####################################### 4 | 5 | ## ---------- ## 6 | ## -- main -- ## 7 | ## ---------- ## 8 | 9 | set -e 10 | 11 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 12 | 13 | PROJ_DIR=$(dirname $DIR) 14 | 15 | cd ${PROJ_DIR} 16 | 17 | bin/auto-config-with-template.sh $@ .env.template 18 | 19 | -------------------------------------------------------------------------------- /bin/auto-config-with-template.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | set -e 4 | 5 | ################################ Usage ####################################### 6 | 7 | #### ------------------------------- #### 8 | #### ---- Docker:docker-compose ---- #### 9 | #### ---- App:Specification: ---- #### 10 | #### ------------------------------- #### 11 | 12 | # DOCKER_HOST_IP=10.128.1.123 13 | # DOCKER_HOST_NAME=server01.openkbs.org 14 | 15 | function usage() { 16 | echo "-----------------------------------------------------------------------------------------------" 17 | echo "Usage:" 18 | echo " $(basename $0) [-i : Use IP Address instead of Hostname]" 19 | echo " [-n : Use Hostname instead of IP]" 20 | echo " [-l]: Use localhost,127.0.0.1 as Docker Host's Hostname/IP Address ]" 21 | echo "-----------------------------------------------------------------------------------------------" 22 | } 23 | 24 | ## ---------- ## 25 | ## -- main -- ## 26 | ## ---------- ## 27 | 28 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 29 | 30 | PROJ_DIR=$(dirname $DIR) 31 | 32 | CONTAINER_NAME=$(basename $PROJ_DIR) 33 | 34 | ## ----------------------- 35 | ## -- Organization Name -- 36 | ## ----------------------- 37 | ORG_NAME=${ORG_NAME:-openkbs} 38 | 39 | TEMPLATE_FILE="docker-compose.yml.template" 40 | TEMPLATE_FILE_PATH=${PROJ_DIR}/${TEMPLATE_FILE} 41 | 42 | SED_MAC_FIX="''" 43 | 44 | CP_OPTION="--backup=numbered" 45 | 46 | ## ------------------------------------------ 47 | ## -- To find the HOST IP for Docker -- 48 | ## -- Container to pass into Container -- 49 | ## -- This will handle both Unix and MacOS -- 50 | ## ------------------------------------------ 51 | HOST_IP=127.0.0.1 52 | function find_host_ip() { 53 | if [[ "$OSTYPE" == "linux-gnu" ]]; then 54 | # ... 55 | HOST_IP=`ip route get 1|grep via | awk '{print $7}'` 56 | SED_MAC_FIX= 57 | echo ${HOST_IP} 58 | elif [[ "$OSTYPE" == "darwin"* ]]; then 59 | # Mac OSX 60 | HOST_IP=`ifconfig | grep "inet " | grep -Fv 127.0.0.1 | grep -Fv 192.168 | awk '{print $2}'` 61 | CP_OPTION= 62 | echo ${HOST_IP} 63 | fi 64 | } 65 | find_host_ip 66 | 67 | #### ---- Docker HOST's IP ---- 68 | #DOCKER_HOST_IP=`ip route get 1|grep via | awk '{print $7}'` 69 | DOCKER_HOST_IP=${HOST_IP} 70 | DOCKER_HOST_NAME=`hostname -f` 71 | 72 | ## -- Variables to initialization: -- 73 | 74 | countShift=0 75 | function processFlags() { 76 | moreFlag=1 77 | while [ $moreFlag -gt 0 ] ; do 78 | case $1 in 79 | "-l") 80 | DOCKER_HOST_IP="127.0.0.1" 81 | DOCKER_HOST_NAME="localhost" 82 | TEMPLATE_FILE=".env.template" 83 | countShift=$((countShift+1)) 84 | shift 85 | ;; 86 | "-i") 87 | DOCKER_HOST_IP=$2 88 | echo "--- Use the given HOstname or IP address to generate .env file" 89 | countShift=$((countShift+2)) 90 | shift 2 91 | ;; 92 | "-n") 93 | DOCKER_HOST_NAME=$2 94 | echo "--- Use the given HOstname or IP address to generate .env file" 95 | countShift=$((countShift+2)) 96 | shift 2 97 | ;; 98 | *) 99 | moreFlag=0 100 | usage 101 | ;; 102 | esac 103 | done 104 | } 105 | 106 | 107 | echo "========> Before processFlags: $*" 108 | 109 | if [ $# -gt 0 ]; then 110 | echo "$@" 111 | processFlags "$@" 112 | fi 113 | 114 | while [ $countShift -gt 0 ]; do 115 | countShift=$((countShift-1)) 116 | shift 1 117 | done 118 | echo "Remaining arguments: $*" 119 | 120 | TEMPLATE_FILE_PATH=$1 121 | 122 | echo "## ---- check the exsitence of template file: ${TEMPLATE_FILE_PATH}" 123 | if [ ! -s "${TEMPLATE_FILE_PATH}" ]; then 124 | echo "*** ERROR: Template file: ${TEMPLATE_FILE_PATH} not found! Abort" 125 | exit 1 126 | else 127 | echo "--- OK: Template file: ${TEMPLATE_FILE_PATH} found! Continue ..." 128 | fi 129 | 130 | ## ------------------------------------------ 131 | ## -- To replace pattern in a file -- 132 | ## ------------------------------------------ 133 | function replaceValueInConfig() { 134 | FILE=${1} 135 | KEY=${2} 136 | VALUE=${3} 137 | search=`cat $FILE|grep "$KEY"` 138 | if [ "$search" = "" ]; then 139 | echo "-- Not found: Append into the file" 140 | echo "$KEY=$VALUE" >> $FILE 141 | else 142 | sed -i ${SED_MAC_FIX} 's/^[[:blank:]]*\('$KEY'[[:blank:]]*=\).*/\1'$VALUE'/g' $FILE 143 | fi 144 | echo "results (after replacement) with new value:" 145 | cat $FILE |grep $KEY 146 | } 147 | 148 | files="${TEMPLATE_FILE_PATH}" 149 | 150 | cd ${PROJ_DIR} 151 | 152 | for f in $files; do 153 | echo "=============== Generating config file from: $f ==================" 154 | AUTO_GEN_FILE=${f%.*}.AUTO 155 | echo "...... AUTO_GEN_FILE= $AUTO_GEN_FILE" 156 | cp $f ${AUTO_GEN_FILE} 157 | sed -i ${SED_MAC_FIX} "s#{{CONTAINER_NAME}}#$CONTAINER_NAME#g" ${AUTO_GEN_FILE} 158 | sed -i ${SED_MAC_FIX} "s#{{DOCKER_HOST_IP}}#$DOCKER_HOST_IP#g" ${AUTO_GEN_FILE} 159 | sed -i ${SED_MAC_FIX} "s#{{DOCKER_HOST_NAME}}#$DOCKER_HOST_NAME#g" ${AUTO_GEN_FILE} 160 | sed -i ${SED_MAC_FIX} "s#{{ORG_NAME}}#$ORG_NAME#g" ${AUTO_GEN_FILE} 161 | cat ${AUTO_GEN_FILE} 162 | #diff $f ${AUTO_GEN_FILE} 163 | echo "---- Auto-generated file: ${AUTO_GEN_FILE}" 164 | # Template file name should be .env.template or docker-compose.yml.template: 165 | # So, the trailing ".template" will be removed to be used to generate the target file. 166 | target_filename=${f%%.template} # docker-compose.yml 167 | if [ -s ]; then 168 | if [ ! -d ${target_filename}.BACKUP ]; then 169 | mkdir -p ${target_filename}.BACKUP 170 | fi 171 | cp ${CP_OPTION} ${target_filename} ${target_filename}.BACKUP/ 172 | echo "... Old ${target_filename} file is save to: ${target_filename}.BACKUP/" 173 | #mv ${target_filename} ${target_filename}.BACKUP/${target_filename}_$(date '+%F').SAVE 174 | # echo "... Old ${target_filename} file is save to: ${target_filename}_$(date '+%F').SAVE" 175 | fi 176 | mv ${AUTO_GEN_FILE} ${target_filename} 177 | done 178 | 179 | -------------------------------------------------------------------------------- /bin/create-venv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -lt 1 ]; then 4 | echo "Need project directory name for creating venv... Abort now!" 5 | echo "---- Usage-1: " 6 | echo " source $(basename $0) " 7 | echo "---- Usage-2: (assuming you install virtualenvwrapper and virutalenv)" 8 | echo " mkvirtualenv ${PROJECT_HOME}" 9 | echo " workon ${PROJECT_HOME}" 10 | exit 1 11 | fi 12 | 13 | PROJECT_HOME=${1:-my_env} 14 | 15 | PYTHON_VERSION=3 16 | #PYTHON_VERSION=3.6 17 | 18 | ########################################################################### 19 | #### ---------------------- DON'T CHANGE BELOW ----------------------- #### 20 | ########################################################################### 21 | #### ---- Detect [python3] is installed ---- #### 22 | #### common location: /usr/bin/python3 23 | VENV_SETUP=`cat ~/.bashrc | grep -i VIRTUALENVWRAPPER_PYTHON` 24 | if [ ! "${VENV_SETUP}" = "" ]; then 25 | echo ".. virtualenvwrapper alreay has been setup!" 26 | exit 0 27 | fi 28 | 29 | #### ---- Detect [python3] is installed ---- #### 30 | #### common location: /usr/bin/python3 31 | PYTHON_EXE=`which python${PYTHON_VERSION}` 32 | if [ "${PYTHON_EXE}" = "" ]; then 33 | echo "**** ERROR: Can't find ${PYTHON_EXE} ! .. Abort setup!" 34 | exit 1 35 | fi 36 | 37 | #### ---- Detect [virtualenv] is installed ---- #### 38 | #### common location: /usr/local/bin/virtualenv 39 | VIRTUALENV_EXE=`which virtualenv` 40 | if [ "${VIRTUALENV_EXE}" = "" ]; then 41 | echo "**** ERROR: Can't find virtualenv executable ! .. Abort setup!" 42 | exit 1 43 | fi 44 | 45 | #### ---- Detect [virtualenvwrapper] is installed ---- #### 46 | #### common location: /usr/local/bin/virtualenvwrapper.sh 47 | VIRTUALENVWRAPPER_SHELL=`which virtualenvwrapper.sh` 48 | if [ "${VIRTUALENVWRAPPER_SHELL}" = "" ]; then 49 | echo "**** ERROR: Can't find virtualenvwrapper.sh script! .. Abort setup!" 50 | exit 1 51 | fi 52 | 53 | ######################################################################### 54 | #### ---- Customization for multiple virtual python environment ---- #### 55 | #### (most recommended approach and simple to switch venv) #### 56 | ######################################################################### 57 | #### Ref: https://virtualenvwrapper.readthedocs.io/en/latest/install.html 58 | #### Ref: https://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html 59 | #### mkvirtualenv [-a project_path] [-i package] [-r requirements_file] [virtualenv options] ENVNAME 60 | 61 | #### ---- root directory for venv setups ---- #### 62 | export WORKON_HOME=~/Envs 63 | echo "WORKON_HOME=${WORKON_HOME}" 64 | if [ ! -d $WORKON_HOME ]; then 65 | mkdir -p $WORKON_HOME 66 | fi 67 | 68 | export VIRTUALENVWRAPPER_PYTHON=${PYTHON_EXE} 69 | export VIRTUALENVWRAPPER_VIRTUALENV=${VIRTUALENV_EXE} 70 | 71 | source ${VIRTUALENVWRAPPER_SHELL} 72 | 73 | # To create & activate your default venv environment, say, "${PROJECT_HOME}" 74 | echo "------" 75 | unset PYTHONPATH 76 | mkvirtualenv ${PROJECT_HOME} 77 | workon ${PROJECT_HOME} 78 | 79 | -------------------------------------------------------------------------------- /bin/setup_venv_bash_profile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PROJECT_HOME=${1:-my-env} 4 | 5 | PYTHON_VERSION=3 6 | #PYTHON_VERSION=3.6 7 | 8 | ########################################################################### 9 | #### ---------------------- DON'T CHANGE BELOW ----------------------- #### 10 | ########################################################################### 11 | 12 | #### ---- Detect [python3] is installed ---- #### 13 | #### common location: /usr/bin/python3 14 | VENV_SETUP=`cat ~/.bashrc | grep -i VIRTUALENVWRAPPER_PYTHON` 15 | if [ ! "${VENV_SETUP}" = "" ]; then 16 | echo ".. virtualenvwrapper alreay has been setup!" 17 | exit 0 18 | fi 19 | 20 | #### ---- Detect [python3] is installed ---- #### 21 | #### common location: /usr/bin/python3 22 | PYTHON_EXE=`which python${PYTHON_VERSION}` 23 | if [ "${PYTHON_EXE}" = "" ]; then 24 | echo "**** ERROR: Can't find ${PYTHON_EXE} ! .. Abort setup!" 25 | exit 1 26 | fi 27 | 28 | #### ---- Detect [virtualenv] is installed ---- #### 29 | #### common location: /usr/local/bin/virtualenv 30 | VIRTUALENV_EXE=`which virtualenv` 31 | if [ "${VIRTUALENV_EXE}" = "" ]; then 32 | echo "**** ERROR: Can't find virtualenv executable ! .. Abort setup!" 33 | exit 1 34 | fi 35 | 36 | #### ---- Detect [virtualenvwrapper] is installed ---- #### 37 | #### common location: /usr/local/bin/virtualenvwrapper.sh 38 | #### Or, source /home/developer/.local/bin/virtualenvwrapper.sh 39 | # 40 | if [ -d /home/developer/.local/bin ]; then 41 | export PATH=$PATH:/home/developer/.local/bin 42 | fi 43 | VIRTUALENVWRAPPER_SHELL=`which virtualenvwrapper.sh` 44 | if [ "${VIRTUALENVWRAPPER_SHELL}" = "" ]; then 45 | echo "**** ERROR: Can't find virtualenvwrapper.sh script! .. Abort setup!" 46 | if [ -s /home/developer/.local/bin/virtualenvwrapper.sh ]; then 47 | VIRTUALENVWRAPPER_SHELL=/home/developer/.local/bin/virtualenvwrapper.sh 48 | else 49 | exit 1 50 | fi 51 | fi 52 | 53 | #### ---- Setup User's HOME profile to run virutalenvwrapper shell script --- 54 | 55 | cat <> ~/.bashrc 56 | 57 | ######################################################################### 58 | #### ---- Customization for multiple virtual python environment ---- #### 59 | #### (most recommended approach and simple to switch venv) #### 60 | ######################################################################### 61 | #### Ref: https://virtualenvwrapper.readthedocs.io/en/latest/install.html 62 | #### Ref: https://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html 63 | #### mkvirtualenv [-a project_path] [-i package] [-r requirements_file] [virtualenv options] ENVNAME 64 | 65 | #### ---- root directory for venv setups ---- #### 66 | export WORKON_HOME=~/Envs 67 | echo "WORKON_HOME=\${WORKON_HOME}" 68 | if [ ! -d \$WORKON_HOME ]; then 69 | mkdir -p \$WORKON_HOME 70 | fi 71 | 72 | export VIRTUALENVWRAPPER_PYTHON=${PYTHON_EXE} 73 | export VIRTUALENVWRAPPER_VIRTUALENV=${VIRTUALENV_EXE} 74 | 75 | source ${VIRTUALENVWRAPPER_SHELL} 76 | 77 | # To create & activate your default venv environment, say, "${PROJECT_HOME}" 78 | echo "------" 79 | unset PYTHONPATH 80 | mkvirtualenv ${PROJECT_HOME:-myvenv} 81 | workon ${PROJECT_HOME:-myvenv} 82 | 83 | EOF 84 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Reference: 6 | # - https://docs.docker.com/engine/userguide/containers/dockerimages/ 7 | # - https://github.com/dockerfile/java/blob/master/oracle-java8/Dockerfile 8 | 9 | if [ $# -lt 1 ]; then 10 | echo "-------------------------------------------------------------------------------------------" 11 | echo "Usage: " 12 | echo " ${0} [ [] ] " 13 | echo "e.g." 14 | echo " ./build.sh ./centos/Dockerfile.centos.xfce.vnc openkbs/centos-xfce-vnc --no-cache --build-arg OS_TYPE=centos'" 15 | echo " ./build.sh ./Dockerfile.ubuntu.xfce.vnc openkbs/ubuntu-xfce-vnc --no-cache --build-arg OS_TYPE=centos'" 16 | echo "-------------------------------------------------------------------------------------------" 17 | fi 18 | 19 | DOCKERFILE=${1:-./Dockerfile} 20 | if [[ "$OSTYPE" == "linux-gnu" ]]; then 21 | # Linux 22 | MY_DIR=$(dirname "$(readlink -f "$0")") 23 | DOCKERFILE=$(realpath $DOCKERFILE) 24 | elif [[ "$OSTYPE" == "darwin"* ]]; then 25 | # Mac OSX 26 | MY_DIR=`pwd` 27 | else 28 | MY_DIR=`pwd` 29 | fi 30 | 31 | BUILD_CONTEXT=$(dirname ${DOCKERFILE}) 32 | 33 | imageTag=${2} 34 | 35 | if [ $# -gt 2 ]; then 36 | shift 2 37 | options="$*" 38 | else 39 | options="" 40 | fi 41 | 42 | ########################################################## 43 | #### ---- Whether to remove previous build cache ---- #### 44 | #### ---- Valid value: 0 (No remove); 1 (yes, remove) 45 | ########################################################## 46 | REMOVE_CACHE=0 47 | 48 | ############################################################################### 49 | ############################################################################### 50 | ############################################################################### 51 | #### ---- DO NOT Change the code below UNLESS you really want to !!!!) --- #### 52 | #### ---- DO NOT Change the code below UNLESS you really want to !!!!) --- #### 53 | #### ---- DO NOT Change the code below UNLESS you really want to !!!!) --- #### 54 | ############################################################################### 55 | ############################################################################### 56 | ############################################################################### 57 | 58 | ########################################################## 59 | #### ---- Generate remove cache option if needed ---- #### 60 | ########################################################## 61 | REMOVE_CACHE_OPTION="" 62 | if [ ${REMOVE_CACHE} -gt 0 ]; then 63 | REMOVE_CACHE_OPTION="--no-cache --rm" 64 | fi 65 | 66 | ################################################### 67 | #### ---- Change this only if want to use your own 68 | ################################################### 69 | ORGANIZATION=openkbs 70 | 71 | ################################################### 72 | #### ---- Detect Docker Run Env files ---- 73 | ################################################### 74 | 75 | function detectDockerBuildEnvFile() { 76 | curr_dir=`pwd` 77 | if [ -s "${DOCKER_ENV_FILE}" ]; then 78 | echo "--- INFO: Docker Build Environment file '${DOCKER_ENV_FILE}' FOUND!" 79 | else 80 | echo "*** WARNING: Docker Build Environment file '${DOCKER_ENV_FILE}' NOT found!" 81 | echo "*** WARNING: Searching for .env or docker.env as alternative!" 82 | echo "*** --->" 83 | if [ -s "./docker-build.env" ]; then 84 | echo "--- INFO: ./docker-build.env FOUND to use as Docker Run Environment file!" 85 | DOCKER_ENV_FILE="./docker-build.env" 86 | else 87 | if [ -s "./.env" ]; then 88 | echo "--- INFO: ./.env FOUND to use as Docker Run Environment file!" 89 | DOCKER_ENV_FILE="./.env" 90 | else 91 | echo "--- INFO: ./.env Docker Environment file (.env) NOT found!" 92 | if [ -s "./docker.env" ]; then 93 | echo "--- INFO: ./docker.env FOUND to use as Docker Run Environment file!" 94 | DOCKER_ENV_FILE="./docker.env" 95 | else 96 | echo "*** WARNING: Docker Environment file (.env) or (docker.env) NOT found!" 97 | fi 98 | fi 99 | fi 100 | fi 101 | } 102 | detectDockerBuildEnvFile 103 | 104 | ################################################### 105 | #### ---- Container package information ---- 106 | ################################################### 107 | DOCKER_IMAGE_REPO=`echo $(basename $PWD)|tr '[:upper:]' '[:lower:]'|tr "/: " "_" ` 108 | imageTag=${imageTag:-"${ORGANIZATION}/${DOCKER_IMAGE_REPO}"} 109 | 110 | ################################################### 111 | #### ---- Generate build-arg arguments ---- 112 | ################################################### 113 | BUILD_ARGS="" 114 | BUILD_DATE="`date -u +"%Y-%m-%dT%H:%M:%SZ"`" 115 | VCS_REF="`git rev-parse --short HEAD`" 116 | VCS_URL="https://github.com/`echo $(basename $PWD)`" 117 | BUILD_ARGS="--build-arg BUILD_DATE=${BUILD_DATE} --build-arg VCS_REF=${VCS_REF}" 118 | 119 | ## -- ignore entries start with "#" symbol -- 120 | function generateBuildArgs() { 121 | if [ "${DOCKER_ENV_FILE}" != "" ] && [ -s "${DOCKER_ENV_FILE}" ]; then 122 | for r in `cat ${DOCKER_ENV_FILE} | grep -v '^#'`; do 123 | echo "entry=> $r" 124 | key=`echo $r | tr -d ' ' | cut -d'=' -f1` 125 | value=`echo $r | tr -d ' ' | cut -d'=' -f2` 126 | BUILD_ARGS="${BUILD_ARGS} --build-arg $key=$value" 127 | done 128 | fi 129 | } 130 | generateBuildArgs 131 | echo "BUILD_ARGS=${BUILD_ARGS}" 132 | 133 | ################################################### 134 | #### ---- Setup Docker Build Proxy ---- 135 | ################################################### 136 | # export NO_PROXY="localhost,127.0.0.1,.openkbs.org" 137 | # export HTTP_PROXY="http://gatekeeper-w.openkbs.org:80" 138 | # when using "wget", add "--no-check-certificate" to avoid https certificate checking failures 139 | # 140 | echo "... Setup Docker Build Proxy: ..." 141 | PROXY_PARAM= 142 | function generateProxyArgs() { 143 | if [ "${HTTP_PROXY}" != "" ]; then 144 | PROXY_PARAM="${PROXY_PARAM} --build-arg HTTP_PROXY=${HTTP_PROXY}" 145 | fi 146 | if [ "${HTTPS_PROXY}" != "" ]; then 147 | PROXY_PARAM="${PROXY_PARAM} --build-arg HTTPS_PROXY=${HTTPS_PROXY}" 148 | fi 149 | if [ "${NO_PROXY}" != "" ]; then 150 | PROXY_PARAM="${PROXY_PARAM} --build-arg NO_PROXY=\"${NO_PROXY}\"" 151 | fi 152 | if [ "${http_proxy}" != "" ]; then 153 | PROXY_PARAM="${PROXY_PARAM} --build-arg http_proxy=${http_proxy}" 154 | fi 155 | if [ "${https_proxy}" != "" ]; then 156 | PROXY_PARAM="${PROXY_PARAM} --build-arg https_proxy=${https_proxy}" 157 | fi 158 | if [ "${no_proxy}" != "" ]; then 159 | PROXY_PARAM="${PROXY_PARAM} --build-arg no_proxy=\"${no_proxy}\"" 160 | fi 161 | BUILD_ARGS="${BUILD_ARGS} ${PROXY_PARAM}" 162 | } 163 | generateProxyArgs 164 | echo -e "BUILD_ARGS=> \n ${BUILD_ARGS}" 165 | echo 166 | 167 | ################################################### 168 | #### ----------- Build Container ------------ ##### 169 | ################################################### 170 | 171 | cd ${BUILD_CONTEXT} 172 | set -x 173 | sudo docker build ${REMOVE_CACHE_OPTION} -t ${imageTag} \ 174 | ${BUILD_ARGS} \ 175 | ${options} \ 176 | -f $(basename ${DOCKERFILE}) . 177 | set +x 178 | cd - 179 | 180 | ################################################### 181 | #### --------- More Guides for Users -------- ##### 182 | ################################################### 183 | 184 | echo "----> Shell into the Container in interactive mode: " 185 | echo " docker exec -it --name /bin/bash" 186 | echo "e.g." 187 | echo " docker run --name "my-$(basename $imageTag)" /bin/bash " 188 | 189 | echo "----> Run: " 190 | echo " docker run --name -it ${imageTag} /bin/bash" 191 | echo "e.g." 192 | echo " docker run --name "my-$(basename $imageTag)" ${imageTag} " 193 | 194 | echo "----> Run in interactive mode: " 195 | echo " docker run -it --name ${imageTag} /bin/bash" 196 | echo "e.g." 197 | echo " docker run -it --name "my-$(basename $imageTag)" -it ${imageTag} " 198 | 199 | echo "----> Build Docker Images again: " 200 | echo "To build again: (there is a dot at the end of the command!)" 201 | echo " docker build -t ${imageTag} . " 202 | echo 203 | sudo docker images |grep "$imageTag" 204 | 205 | -------------------------------------------------------------------------------- /certificates/dummy.crt: -------------------------------------------------------------------------------- 1 | test 2 | -------------------------------------------------------------------------------- /certificates/openkbs-BA-NPE-CA-3.crt: -------------------------------------------------------------------------------- 1 | test 2 | -------------------------------------------------------------------------------- /certificates/root.cert.pem: -------------------------------------------------------------------------------- 1 | test 2 | -------------------------------------------------------------------------------- /clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | MY_DIR=$(dirname "$(readlink -f "$0")") 4 | 5 | if [ $# -lt 1 ]; then 6 | echo "------------- Clean up both Container and Images -------------" 7 | echo "Usage: " 8 | echo " ${0} []" 9 | echo "e.g.: " 10 | echo " ${0} tensorflow-python3-jupyter " 11 | echo " ${0} " 12 | echo " (empty argument will use default the current git container name to clean up)" 13 | fi 14 | 15 | ################################################### 16 | #### ---- Change this only to use your own ---- 17 | ################################################### 18 | ORGANIZATION=openkbs 19 | baseDataFolder="$HOME/data-docker" 20 | 21 | ################################################### 22 | #### **** Container package information **** 23 | ################################################### 24 | DOCKER_IMAGE_REPO=`echo $(basename $PWD)|tr '[:upper:]' '[:lower:]'|tr "/: " "_" ` 25 | imageTag="${ORGANIZATION}/${DOCKER_IMAGE_REPO}" 26 | 27 | ## -- transform '-' and space to '_' 28 | #instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/\-: " "_"` 29 | instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/: " "_"` 30 | 31 | echo "---------------------------------------------" 32 | echo "---- Clean up the Container for ${imageTag}" 33 | echo "---------------------------------------------" 34 | 35 | if [ $1 ]; then 36 | imageTag="$1" 37 | fi 38 | 39 | containers=`docker ps -a | grep ${imageTag} | awk '{print $1}' ` 40 | 41 | if [ $containers ]; then 42 | docker rm -f $containers 43 | fi 44 | 45 | for IMAGE_ID in `docker images -a | grep ${imageTag} | awk '{print $3}' `; do 46 | children=$(docker images --filter since=${IMAGE_ID} -q) 47 | if [[ ! $children == *"No such image"* ]]; then 48 | id=$(docker inspect --format='{{.Id}} {{.Parent}}' $children |cut -d':' -f2|cut -c-12) 49 | if [ "$id" != "" ]; then 50 | docker rmi -f $id 51 | fi 52 | fi 53 | done 54 | 55 | 56 | -------------------------------------------------------------------------------- /commit-push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Reference: 4 | # - https://docs.docker.com/engine/userguide/containers/dockerimages/ 5 | # - https://docs.docker.com/engine/reference/commandline/commit/ 6 | # docker push [OPTIONS] NAME[:TAG] 7 | # - https://docs.docker.com/engine/reference/commandline/push/ 8 | # docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]] 9 | 10 | echo "Usage: " 11 | echo " ${0} [] []" 12 | echo "e.g." 13 | echo " ${0} \"initial updates\" \"openkbs/docker-project-tempalte\" \"1.0.0\" " 14 | echo "" 15 | echo "-------------------------------------" 16 | echo "-- Make sure you do login first: --" 17 | echo "-- To login:" 18 | echo " docker login" 19 | echo "-------------------------------------" 20 | echo 21 | 22 | ORGANIZATION=${ORGANIZATION:-openkbs} 23 | 24 | comment=${1:-Update with the latest changes: `date`} 25 | 26 | ################################################### 27 | #### **** Container package information **** 28 | ################################################### 29 | DOCKER_IMAGE_REPO=`echo $(basename $PWD)|tr '[:upper:]' '[:lower:]'|tr "/: " "_" ` 30 | imageTag=${2:-"${ORGANIZATION}/${DOCKER_IMAGE_REPO}"} 31 | imageVersion=${3:-latest} 32 | 33 | docker ps -a 34 | 35 | containerID=`docker ps |grep "${imageTag} "|awk '{print $1}'` 36 | echo "containerID=$containerID" 37 | 38 | #docker tag ${imageTag} ${imageTag}:latest 39 | 40 | #docker commit -m "$comment" ${containerID} ${imageTag}:latest 41 | #docker push ${imageTag}:latest 42 | 43 | echo docker commit -m "$comment" ${containerID} ${imageTag}:${imageVersion} 44 | echo docker push ${imageTag}:${imageVersion} 45 | -------------------------------------------------------------------------------- /doc/KNIME-docker-IDE_v.3.7.0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DrSnowbird/knime-docker/86bf236cfe1fee47f82a3d6c49a69db0e0cf6336/doc/KNIME-docker-IDE_v.3.7.0.png -------------------------------------------------------------------------------- /doc/KNIME-docker-compose-demo.flv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DrSnowbird/knime-docker/86bf236cfe1fee47f82a3d6c49a69db0e0cf6336/doc/KNIME-docker-compose-demo.flv -------------------------------------------------------------------------------- /doc/KNIME-docker-run.sh-demo.flv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DrSnowbird/knime-docker/86bf236cfe1fee47f82a3d6c49a69db0e0cf6336/doc/KNIME-docker-run.sh-demo.flv -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | knime-docker: 4 | image: openkbs/knime-docker 5 | build: 6 | context: . 7 | dockerfile: Dockerfile 8 | container_name: knime-docker 9 | environment: 10 | - USER_ID=${USER_ID:-1000} 11 | - GROUP_ID=${GROUP_ID:-1000} 12 | env_file: 13 | - .env 14 | volumes: 15 | - /tmp/.X11-unix:/tmp/.X11-unix 16 | - ./workspace:/home/developer/workspace 17 | - ./.eclipse:/home/developer/.eclipse 18 | 19 | -------------------------------------------------------------------------------- /logs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | MY_DIR=$(dirname "$(readlink -f "$0")") 4 | 5 | if [ $# -lt 1 ]; then 6 | echo "Usage: " 7 | echo " ${0} " 8 | echo "e.g.: " 9 | echo " ${0} ls -al " 10 | fi 11 | 12 | ################################################### 13 | #### ---- Change this only to use your own ---- 14 | ################################################### 15 | ORGANIZATION=openkbs 16 | baseDataFolder="$HOME/data-docker" 17 | 18 | ################################################### 19 | #### **** Container package information **** 20 | ################################################### 21 | DOCKER_IMAGE_REPO=`echo $(basename $PWD)|tr '[:upper:]' '[:lower:]'|tr "/: " "_" ` 22 | imageTag="${ORGANIZATION}/${DOCKER_IMAGE_REPO}" 23 | 24 | ## -- transform '-' and space to '_' 25 | #instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/\-: " "_"` 26 | instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/: " "_"` 27 | 28 | echo "---------------------------------------------" 29 | echo "---- Print Log for Container for ${imageTag}" 30 | echo "---------------------------------------------" 31 | sudo docker logs ${instanceName} 32 | 33 | 34 | -------------------------------------------------------------------------------- /restore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | MY_DIR=$(dirname "$(readlink -f "$0")") 4 | 5 | if [ $# -lt 1 ]; then 6 | echo "Usage: " 7 | echo " ${0} [Different tgz Docker Image file]" 8 | echo "e.g.: " 9 | echo " ${0} " 10 | fi 11 | 12 | ################################################### 13 | #### ---- Change this only to use your own ---- 14 | ################################################### 15 | ORGANIZATION=openkbs 16 | 17 | ################################################### 18 | #### **** Container package information **** 19 | ################################################### 20 | DOCKER_IMAGE_REPO=`echo $(basename $PWD)|tr '[:upper:]' '[:lower:]'|tr "/: " "_" ` 21 | imageTag="${ORGANIZATION}/${DOCKER_IMAGE_REPO}" 22 | 23 | ################################################### 24 | #### ---- Mostly, you don't need change below ---- 25 | ################################################### 26 | ## -- transform '-' and space to '_' 27 | #instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/\-: " "_"` 28 | instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/: " "_"` 29 | 30 | TGZ_DOCKER_IMAGE=${1:-${instanceName}.tgz} 31 | 32 | function restore() { 33 | if [ ! -s ${TGZ_DOCKER_IMAGE} ]; then 34 | echo "*** ERROR ***: Can't find image (*.tgz or tar.gz) file: Can't continue! Abort!" 35 | exit 1 36 | fi 37 | gunzip -c ${TGZ_DOCKER_IMAGE} | docker load 38 | sudo docker images | grep ${TGZ_DOCKER_IMAGE%.tgz} 39 | } 40 | 41 | echo "---------------------------------------------" 42 | echo "---- SAVE a Container for ${imageTag}" 43 | echo "---------------------------------------------" 44 | 45 | restore 46 | 47 | 48 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set +e 4 | 5 | MY_DIR=$(dirname "$(readlink -f "$0")") 6 | 7 | if [ $# -lt 1 ]; then 8 | echo "--------------------------------------------------------" 9 | echo "Usage: " 10 | echo " ${0} " 11 | echo "e.g.: " 12 | echo " ${0} ls -al " 13 | echo " ${0} /bin/bash " 14 | echo "--------------------------------------------------------" 15 | fi 16 | 17 | ########################################################################### 18 | #### ---- RUN Configuration (CHANGE THESE if needed!!!!) --- #### 19 | ########################################################################### 20 | ## ------------------------------------------------------------------------ 21 | ## Valid "BUILD_TYPE" values: 22 | ## 0: (default) has neither X11 nor VNC/noVNC container build image type 23 | ## 1: X11/Desktip container build image type 24 | ## 2: VNC/noVNC container build image type 25 | ## ------------------------------------------------------------------------ 26 | BUILD_TYPE=1 27 | 28 | ## ------------------------------------------------------------------------ 29 | ## Valid "RUN_TYPE" values: 30 | ## 0: (default) Interactive Container - 31 | ## ==> Best for Debugging Use 32 | ## 1: Detach Container / Non-Interactive 33 | ## ==> Usually, when not in debugging mode anymore, then use 1 as choice. 34 | ## ==> Or, your frequent needs of the container for DEV environment Use. 35 | ## ------------------------------------------------------------------------ 36 | if [ "$1" = "-d" ]; then 37 | RUN_TYPE=1 38 | shift 1 39 | fi 40 | RUN_TYPE=${RUN_TYPE:-0} 41 | 42 | ## ------------------------------------------------------------------------ 43 | ## Change to one (1) if run.sh needs to use host's user/group to run the Container 44 | ## Valid "USER_VARS_NEEDED" values: 45 | ## 0: (default) Not using host's USER / GROUP ID 46 | ## 1: Yes, using host's USER / GROUP ID for Container running. 47 | ## ------------------------------------------------------------------------ 48 | USER_VARS_NEEDED=0 49 | 50 | ## ------------------------------------------------------------------------ 51 | ## Valid "RESTART_OPTION" values: 52 | ## { no, on-failure, unless-stopped, always } 53 | ## ------------------------------------------------------------------------ 54 | if [ "$1" = "-a" ] && [ "${RUN_TYPE}" = "1" ] ; then 55 | RESTART_OPTION=always 56 | shift 1 57 | fi 58 | RESTART_OPTION=${RESTART_OPTION:-no} 59 | 60 | ## ------------------------------------------------------------------------ 61 | ## More optional values: 62 | ## Add any additional options here 63 | ## ------------------------------------------------------------------------ 64 | #MORE_OPTIONS="--privileged=true" 65 | MORE_OPTIONS="" 66 | 67 | ## ------------------------------------------------------------------------ 68 | ## Multi-media optional values: 69 | ## Add any additional options here 70 | ## ------------------------------------------------------------------------ 71 | #MEDIA_OPTIONS=" --device /dev/snd --device /dev/dri --device /dev/video0 --group-add audio --group-add video " 72 | MEDIA_OPTIONS=" --device /dev/snd --device /dev/dri --group-add audio --group-add video " 73 | #MEDIA_OPTIONS= 74 | 75 | ############################################################################### 76 | ############################################################################### 77 | ############################################################################### 78 | #### ---- DO NOT Change the code below UNLESS you really want to !!!!) --- #### 79 | #### ---- DO NOT Change the code below UNLESS you really want to !!!!) --- #### 80 | #### ---- DO NOT Change the code below UNLESS you really want to !!!!) --- #### 81 | ############################################################################### 82 | ############################################################################### 83 | ############################################################################### 84 | 85 | ######################################## 86 | #### ---- Correctness Checking ---- #### 87 | ######################################## 88 | RESTART_OPTION=`echo ${RESTART_OPTION} | sed 's/ //g' | tr '[:upper:]' '[:lower:]' ` 89 | REMOVE_OPTION=" --rm " 90 | if [ "${RESTART_OPTION}" != "no" ]; then 91 | REMOVE_OPTION="" 92 | fi 93 | 94 | ######################################## 95 | #### ---- Usage for BUILD_TYPE ---- #### 96 | ######################################## 97 | function buildTypeUsage() { 98 | echo "## ------------------------------------------------------------------------" 99 | echo "## Valid BUILD_TYPE values: " 100 | echo "## 0: (default) has neither X11 nor VNC/noVNC container build image type" 101 | echo "## 1: X11/Desktip container build image type" 102 | echo "## 2: VNC/noVNC container build image type" 103 | echo "## ------------------------------------------------------------------------" 104 | } 105 | 106 | if [ "${BUILD_TYPE}" -lt 0 ] || [ "${BUILD_TYPE}" -gt 2 ]; then 107 | buildTypeUsage 108 | exit 1 109 | fi 110 | 111 | ######################################## 112 | #### ---- Validate RUN_TYPE ---- #### 113 | ######################################## 114 | 115 | RUN_OPTION=${RUN_OPTION:-" -it "} 116 | function validateRunType() { 117 | case "${RUN_TYPE}" in 118 | 0 ) 119 | RUN_OPTION=" -it " 120 | ;; 121 | 1 ) 122 | RUN_OPTION=" -d " 123 | ;; 124 | * ) 125 | echo "**** ERROR: Incorrect RUN_TYPE: ${RUN_TYPE} is used! Abort ****" 126 | exit 1 127 | ;; 128 | esac 129 | } 130 | validateRunType 131 | echo "RUN_TYPE=${RUN_TYPE}" 132 | echo "RUN_OPTION=${RUN_OPTION}" 133 | echo "RESTART_OPTION=${RESTART_OPTION}" 134 | echo "REMOVE_OPTION=${REMOVE_OPTION}" 135 | 136 | ########################################################################### 137 | ## -- docker-compose or docker-stack use only -- 138 | ########################################################################### 139 | 140 | ## -- (this script will include ./.env only if "./docker-run.env" not found 141 | DOCKER_ENV_FILE="./docker-run.env" 142 | 143 | ########################################################################### 144 | #### (Optional - to filter Environmental Variables for Running Docker) 145 | ########################################################################### 146 | ENV_VARIABLE_PATTERN="" 147 | 148 | ################################################### 149 | #### ---- Change this only to use your own ---- 150 | ################################################### 151 | ORGANIZATION=openkbs 152 | baseDataFolder="$HOME/data-docker" 153 | 154 | ################################################### 155 | #### ---- Detect Host OS Type and minor Tweek: ---- 156 | ################################################### 157 | SED_MAC_FIX="''" 158 | CP_OPTION="--backup=numbered" 159 | HOST_IP=127.0.0.1 160 | function get_HOST_IP() { 161 | if [[ "$OSTYPE" == "linux-gnu" ]]; then 162 | # Linux ... 163 | HOST_IP=`ip route get 1|grep via | awk '{print $7}' ` 164 | SED_MAC_FIX= 165 | elif [[ $OSTYPE == darwin* ]]; then 166 | # Mac OSX 167 | HOST_IP=`ifconfig | grep "inet " | grep -Fv 127.0.0.1 | grep -Fv 192.168 | awk '{print $2}'` 168 | CP_OPTION= 169 | fi 170 | echo "HOST_IP=${HOST_IP}" 171 | } 172 | get_HOST_IP 173 | MY_IP=${HOST_IP} 174 | 175 | ################################################### 176 | #### **** Container package information **** 177 | ################################################### 178 | MY_IP=` hostname -I|awk '{print $1}'` 179 | DOCKER_IMAGE_REPO=`echo $(basename $PWD)|tr '[:upper:]' '[:lower:]'|tr "/: " "_" ` 180 | imageTag="${ORGANIZATION}/${DOCKER_IMAGE_REPO}" 181 | #PACKAGE=`echo ${imageTag##*/}|tr "/\-: " "_"` 182 | PACKAGE="${imageTag##*/}" 183 | 184 | ################################################### 185 | #### ---- (DEPRECATED but still supported) ----- 186 | #### ---- Volumes to be mapped (change this!) ----- 187 | ################################################### 188 | # (examples) 189 | # IDEA_PRODUCT_NAME="IdeaIC2017" 190 | # IDEA_PRODUCT_VERSION="3" 191 | # IDEA_INSTALL_DIR="${IDEA_PRODUCT_NAME}.${IDEA_PRODUCT_VERSION}" 192 | # IDEA_CONFIG_DIR=".${IDEA_PRODUCT_NAME}.${IDEA_PRODUCT_VERSION}" 193 | # IDEA_PROJECT_DIR="IdeaProjects" 194 | # VOLUMES_LIST="${IDEA_CONFIG_DIR} ${IDEA_PROJECT_DIR}" 195 | 196 | # --------------------------- 197 | # Variable: VOLUMES_LIST 198 | # (NEW: use docker.env with "#VOLUMES_LIST=data workspace" to define entries) 199 | # --------------------------- 200 | ## -- If you defined locally here, 201 | ## then the definitions of volumes map in "docker.env" will be ignored. 202 | # VOLUMES_LIST="data workspace" 203 | 204 | # --------------------------- 205 | # OPTIONAL Variable: PORT PAIR 206 | # (NEW: use docker.env with "#PORTS=18000:8000 17200:7200" to define entries) 207 | # --------------------------- 208 | ## -- If you defined locally here, 209 | ## then the definitions of ports map in "docker.env" will be ignored. 210 | #### Input: PORT - list of PORT to be mapped 211 | # (examples) 212 | #PORTS_LIST="18000:8000" 213 | #PORTS_LIST= 214 | 215 | ######################################################################################################### 216 | ######################## DON'T CHANGE LINES STARTING BELOW (unless you need to) ######################### 217 | ######################################################################################################### 218 | LOCAL_VOLUME_DIR="${baseDataFolder}/${PACKAGE}" 219 | ## -- Container's internal Volume base DIR 220 | DOCKER_VOLUME_DIR="/home/developer" 221 | 222 | ################################################### 223 | #### ---- Detect Docker Run Env files ---- 224 | ################################################### 225 | 226 | function detectDockerRunEnvFile() { 227 | curr_dir=`pwd` 228 | if [ -s "${DOCKER_ENV_FILE}" ]; then 229 | echo "--- INFO: Docker Run Environment file '${DOCKER_ENV_FILE}' FOUND!" 230 | else 231 | echo "*** WARNING: Docker Run Environment file '${DOCKER_ENV_FILE}' NOT found!" 232 | echo "*** WARNING: Searching for .env or docker.env as alternative!" 233 | echo "*** --->" 234 | if [ -s "./docker-run.env" ]; then 235 | echo "--- INFO: ./docker-run.env FOUND to use as Docker Run Environment file!" 236 | DOCKER_ENV_FILE="./docker-run.env" 237 | else 238 | if [ -s "./.env" ]; then 239 | echo "--- INFO: ./.env FOUND to use as Docker Run Environment file!" 240 | DOCKER_ENV_FILE="./.env" 241 | else 242 | echo "--- INFO: ./.env Docker Environment file (.env) NOT found!" 243 | if [ -s "./docker.env" ]; then 244 | echo "--- INFO: ./docker.env FOUND to use as Docker Run Environment file!" 245 | DOCKER_ENV_FILE="./docker.env" 246 | else 247 | echo "*** WARNING: Docker Environment file (.env) or (docker.env) NOT found!" 248 | fi 249 | fi 250 | fi 251 | fi 252 | } 253 | detectDockerRunEnvFile 254 | 255 | ################################################### 256 | #### ---- Function: Generate volume mappings ---- 257 | #### (Don't change!) 258 | ################################################### 259 | VOLUME_MAP="" 260 | #### Input: VOLUMES - list of volumes to be mapped 261 | hasPattern=0 262 | function hasPattern() { 263 | detect=`echo $1|grep "$2"` 264 | if [ "${detect}" != "" ]; then 265 | hasPattern=1 266 | else 267 | hasPattern=0 268 | fi 269 | } 270 | 271 | DEBUG=0 272 | function debug() { 273 | if [ $DEBUG -gt 0 ]; then 274 | echo $* 275 | fi 276 | } 277 | 278 | function cutomizedVolume() { 279 | DATA_VOLUME=$1 280 | if [ "`echo $DATA_VOLUME|grep 'volume-'`" != "" ]; then 281 | docker_volume=`echo $DATA_VOLUME | cut -d'-' -f2 | cut -d':' -f1` 282 | dest_volume=`echo $DATA_VOLUME | cut -d'-' -f2 | cut -d':' -f2` 283 | source_volume=$(basename $imageTag)_${docker_volume} 284 | sudo docker volume create ${source_volume} 285 | 286 | VOLUME_MAP="-v ${source_volume}:${dest_volume} ${VOLUME_MAP}" 287 | else 288 | echo "---- ${DATA_VOLUME} already is defined! Hence, ignore setup ${DATA_VOLUME} ..." 289 | echo "---> VOLUME_MAP=${VOLUME_MAP}" 290 | fi 291 | } 292 | 293 | function checkHostVolumePath() { 294 | _left=$1 295 | mkdir -p ${_left} 296 | sudo chown -R $USER:$USER ${_left} 297 | if [ -s ${_left} ]; then 298 | ls -al ${_left} 299 | else 300 | echo "*** ERROR: ${_left}: Not existing!" 301 | fi 302 | } 303 | 304 | function generateVolumeMapping() { 305 | if [ "$VOLUMES_LIST" == "" ]; then 306 | ## -- If locally defined in this file, then respect that first. 307 | ## -- Otherwise, go lookup the docker.env as ride-along source for volume definitions 308 | VOLUMES_LIST=`cat ${DOCKER_ENV_FILE}|grep "^#VOLUMES_LIST= *"|sed "s/[#\"]//g"|cut -d'=' -f2-` 309 | fi 310 | for vol in $VOLUMES_LIST; do 311 | echo 312 | echo ">>>>>>>>> $vol" 313 | hasColon=`echo $vol|grep ":"` 314 | ## -- allowing change local volume directories -- 315 | if [ "$hasColon" != "" ]; then 316 | if [ "`echo $vol|grep 'volume-'`" != "" ]; then 317 | cutomizedVolume $vol 318 | else 319 | echo "************* hasColon=$hasColon" 320 | left=`echo $vol|cut -d':' -f1` 321 | right=`echo $vol|cut -d':' -f2` 322 | leftHasDot=`echo $left|grep "^\./"` 323 | if [ "$leftHasDot" != "" ]; then 324 | ## has "./data" on the left 325 | debug "******** A. Left HAS Dot pattern: leftHasDot=$leftHasDot" 326 | if [[ ${right} == "/"* ]]; then 327 | ## -- pattern like: "./data:/containerPath/data" 328 | echo "******* A-1 -- pattern like ./data:/data --" 329 | VOLUME_MAP="${VOLUME_MAP} -v `pwd`/${left#./}:${right}" 330 | else 331 | ## -- pattern like: "./data:data" 332 | echo "******* A-2 -- pattern like ./data:data --" 333 | VOLUME_MAP="${VOLUME_MAP} -v `pwd`/${left#./}:${DOCKER_VOLUME_DIR}/${right}" 334 | fi 335 | checkHostVolumePath "`pwd`/${left}" 336 | else 337 | ## No "./data" on the left 338 | debug "******** B. Left No ./data on the left: leftHasDot=$leftHasDot" 339 | leftHasAbsPath=`echo $left|grep "^/.*"` 340 | if [ "$leftHasAbsPath" != "" ]; then 341 | debug "******* B-1 ## Has pattern like /data on the left " 342 | if [[ ${right} == "/"* ]]; then 343 | ## -- pattern like: "/data:/containerPath/data" 344 | echo "****** B-1-a pattern like /data:/containerPath/data --" 345 | VOLUME_MAP="${VOLUME_MAP} -v ${left}:${right}" 346 | else 347 | ## -- pattern like: "/data:data" 348 | echo "----- B-1-b pattern like /data:data --" 349 | VOLUME_MAP="${VOLUME_MAP} -v ${left}:${DOCKER_VOLUME_DIR}/${right}" 350 | fi 351 | checkHostVolumePath "${left}" 352 | else 353 | debug "******* B-2 ## No pattern like /data on the left" 354 | rightHasAbsPath=`echo $right|grep "^/.*"` 355 | debug ">>>>>>>>>>>>> rightHasAbsPath=$rightHasAbsPath" 356 | if [[ ${right} == "/"* ]]; then 357 | echo "****** B-2-a pattern like: data:/containerPath/data" 358 | debug "-- pattern like ./data:/data --" 359 | VOLUME_MAP="${VOLUME_MAP} -v ${LOCAL_VOLUME_DIR}/${left}:${right}" 360 | else 361 | debug "****** B-2-b ## -- pattern like: data:data" 362 | VOLUME_MAP="${VOLUME_MAP} -v ${LOCAL_VOLUME_DIR}/${left}:${DOCKER_VOLUME_DIR}/${right}" 363 | fi 364 | checkHostVolumePath "${left}" 365 | fi 366 | fi 367 | fi 368 | else 369 | ## -- pattern like: "data" 370 | debug "-- default sub-directory (without prefix absolute path) --" 371 | VOLUME_MAP="${VOLUME_MAP} -v ${LOCAL_VOLUME_DIR}/$vol:${DOCKER_VOLUME_DIR}/$vol" 372 | mkdir -p ${LOCAL_VOLUME_DIR}/$vol 373 | if [ $DEBUG -gt 0 ]; then ls -al ${LOCAL_VOLUME_DIR}/$vol; fi 374 | fi 375 | echo ">>> expanded VOLUME_MAP: ${VOLUME_MAP}" 376 | done 377 | } 378 | #### ---- Generate Volumes Mapping ---- 379 | generateVolumeMapping 380 | echo ${VOLUME_MAP} 381 | 382 | ################################################### 383 | #### ---- Function: Generate port mappings ---- 384 | #### (Don't change!) 385 | ################################################### 386 | PORT_MAP="" 387 | function generatePortMapping() { 388 | if [ "$PORTS" == "" ]; then 389 | ## -- If locally defined in this file, then respect that first. 390 | ## -- Otherwise, go lookup the ${DOCKER_ENV_FILE} as ride-along source for volume definitions 391 | PORTS_LIST=`cat ${DOCKER_ENV_FILE}|grep "^#PORTS_LIST= *"|sed "s/[#\"]//g"|cut -d'=' -f2-` 392 | fi 393 | for pp in ${PORTS_LIST}; do 394 | #echo "$pp" 395 | port_pair=`echo $pp | tr -d ' ' ` 396 | if [ ! "$port_pair" == "" ]; then 397 | # -p ${local_dockerPort1}:${dockerPort1} 398 | host_port=`echo $port_pair | tr -d ' ' | cut -d':' -f1` 399 | docker_port=`echo $port_pair | tr -d ' ' | cut -d':' -f2` 400 | PORT_MAP="${PORT_MAP} -p ${host_port}:${docker_port}" 401 | fi 402 | done 403 | } 404 | #### ---- Generate Port Mapping ---- 405 | generatePortMapping 406 | echo "PORT_MAP=${PORT_MAP}" 407 | 408 | ################################################### 409 | #### ---- Generate Environment Variables ---- 410 | ################################################### 411 | ENV_VARS="" 412 | function generateEnvVars_v2() { 413 | while read line; do 414 | echo "Line=$line" 415 | key=${line%=*} 416 | value=${line#*=} 417 | key=$(eval echo $value) 418 | ENV_VARS="${ENV_VARS} -e ${line%=*}=$(eval echo $value)" 419 | done < <(grep -E "^[[:blank:]]*$1.+[[:blank:]]*=[[:blank:]]*.+[[:blank:]]*" ${DOCKER_ENV_FILE} | grep -v "^#") 420 | echo "ENV_VARS=$ENV_VARS" 421 | } 422 | generateEnvVars_v2 423 | echo ">> ENV_VARS=$ENV_VARS" 424 | 425 | function generateEnvVars() { 426 | if [ "${1}" != "" ]; then 427 | ## -- product key patterns, e.g., "^MYSQL_*" 428 | #productEnvVars=`grep -E "^[[:blank:]]*$1[a-zA-Z0-9_]+[[:blank:]]*=[[:blank:]]*[a-zA-Z0-9_]+[[:blank:]]*" ${DOCKER_ENV_FILE}` 429 | productEnvVars=`grep -E "^[[:blank:]]*$1.+[[:blank:]]*=[[:blank:]]*.+[[:blank:]]*" ${DOCKER_ENV_FILE} | grep -v "^#" | grep "${1}"` 430 | else 431 | ## -- product key patterns, e.g., "^MYSQL_*" 432 | #productEnvVars=`grep -E "^[[:blank:]]*$1[a-zA-Z0-9_]+[[:blank:]]*=[[:blank:]]*[a-zA-Z0-9_]+[[:blank:]]*" ${DOCKER_ENV_FILE}` 433 | productEnvVars=`grep -E "^[[:blank:]]*$1.+[[:blank:]]*=[[:blank:]]*.+[[:blank:]]*" ${DOCKER_ENV_FILE} | grep -v "^#"` 434 | fi 435 | for vars in 436 | do 437 | echo "Line=$line" 438 | key=${line%=*} 439 | value=${line#*=} 440 | #key=$(eval echo $value) 441 | #ENV_VARS="${ENV_VARS} -e ${line%=*}=$(eval echo $value)" 442 | ENV_VARS="${ENV_VARS} -e ${line}" 443 | done 444 | ENV_VARS_STRING="" 445 | for vars in ${productEnvVars// /}; do 446 | debug "Entry => $vars" 447 | key=${vars%=*} 448 | value=${vars#*=} 449 | if [ "$1" != "" ]; then 450 | matched=`echo $vars|grep -E "${1}"` 451 | if [ ! "$matched" == "" ]; then 452 | ENV_VARS="${ENV_VARS} -e $key=$(eval echo $value)" 453 | #ENV_VARS="${ENV_VARS} ${vars}" 454 | fi 455 | else 456 | #ENV_VARS="${ENV_VARS} ${vars}" 457 | ENV_VARS="${ENV_VARS} -e $key=$(eval echo $value)" 458 | fi 459 | done 460 | # ## IFS default is "space tab newline" already 461 | # #IFS=',; ' read -r -a ENV_VARS_ARRAY <<< "${ENV_VARS_STRING}" 462 | # read -r -a ENV_VARS_ARRAY <<< "${ENV_VARS_STRING}" 463 | # # To iterate over the elements: 464 | # for element in "${ENV_VARS_ARRAY[@]}" 465 | # do 466 | # ENV_VARS="${ENV_VARS} -e ${element}" 467 | # done 468 | # if [ $DEBUG -gt 0 ]; then echo "ENV_VARS_ARRAY=${ENV_VARS_ARRAY[@]}"; fi 469 | } 470 | #generateEnvVars 471 | #echo "ENV_VARS=${ENV_VARS}" 472 | 473 | ################################################### 474 | #### ---- Setup Docker Build Proxy ---- 475 | ################################################### 476 | # export NO_PROXY="localhost,127.0.0.1,.openkbs.org" 477 | # export HTTP_PROXY="http://gatekeeper-w.openkbs.org:80" 478 | # when using "wget", add "--no-check-certificate" to avoid https certificate checking failures 479 | # Note: You can also setup Docker CLI configuration file (~/.docker/config.json), e.g. 480 | # { 481 | # "proxies": { 482 | # "default": { 483 | # "httpProxy": "http://gatekeeper-w.openkbs.org:80" 484 | # "httpsProxy": "http://gatekeeper-w.openkbs.org:80" 485 | # } 486 | # } 487 | # } 488 | # 489 | echo "... Setup Docker Run Proxy: ..." 490 | 491 | PROXY_PARAM= 492 | function generateProxyEnv() { 493 | if [ "${HTTP_PROXY}" != "" ]; then 494 | PROXY_PARAM="${PROXY_PARAM} -e HTTP_PROXY=${HTTP_PROXY}" 495 | fi 496 | if [ "${HTTPS_PROXY}" != "" ]; then 497 | PROXY_PARAM="${PROXY_PARAM} -e HTTPS_PROXY=${HTTPS_PROXY}" 498 | fi 499 | if [ "${NO_PROXY}" != "" ]; then 500 | PROXY_PARAM="${PROXY_PARAM} -e NO_PROXY=\"${NO_PROXY}\"" 501 | fi 502 | if [ "${http_proxy}" != "" ]; then 503 | PROXY_PARAM="${PROXY_PARAM} -e http_proxy=${http_proxy}" 504 | fi 505 | if [ "${https_proxy}" != "" ]; then 506 | PROXY_PARAM="${PROXY_PARAM} -e https_proxy=${https_proxy}" 507 | fi 508 | if [ "${no_proxy}" != "" ]; then 509 | PROXY_PARAM="${PROXY_PARAM} -e no_proxy=\"${no_proxy}\"" 510 | fi 511 | ENV_VARS="${ENV_VARS} ${PROXY_PARAM}" 512 | } 513 | generateProxyEnv 514 | echo "ENV_VARS=${ENV_VARS}" 515 | 516 | ################################################### 517 | #### ---- Function: Generate privilege String ---- 518 | #### (Don't change!) 519 | ################################################### 520 | privilegedString="" 521 | function generatePrivilegedString() { 522 | OS_VER=`which yum` 523 | if [ "$OS_VER" == "" ]; then 524 | # Ubuntu 525 | echo "Ubuntu ... not SE-Lunix ... no privileged needed" 526 | else 527 | # CentOS/RHEL 528 | privilegedString="--privileged" 529 | fi 530 | } 531 | generatePrivilegedString 532 | echo ${privilegedString} 533 | 534 | ################################################### 535 | #### ---- Mostly, you don't need change below ---- 536 | ################################################### 537 | function cleanup() { 538 | containerID=`sudo docker ps -a|grep "${instanceName}" | awk '{print $1}'` 539 | # if [ ! "`sudo docker ps -a|grep ${instanceName}`" == "" ]; then 540 | if [ "${containerID}" != "" ]; then 541 | sudo docker rm -f ${containerID} 542 | fi 543 | } 544 | 545 | function displayURL() { 546 | port=${1} 547 | echo "... Go to: http://${MY_IP}:${port}" 548 | #firefox http://${MY_IP}:${port} & 549 | if [ "`which google-chrome`" != "" ]; then 550 | /usr/bin/google-chrome http://${MY_IP}:${port} & 551 | else 552 | firefox http://${MY_IP}:${port} & 553 | fi 554 | } 555 | 556 | ################################################### 557 | #### ---- Replace "Key=Value" with new value ---- 558 | ################################################### 559 | function replaceKeyValue() { 560 | inFile=${1:-${DOCKER_ENV_FILE}} 561 | keyLike=$2 562 | newValue=$3 563 | if [ "$2" == "" ]; then 564 | echo "**** ERROR: Empty Key value! Abort!" 565 | exit 1 566 | fi 567 | sed -i -E 's/^('$keyLike'[[:blank:]]*=[[:blank:]]*).*/\1'$newValue'/' $inFile 568 | } 569 | #### ---- Replace docker.env with local user's UID and GID ---- 570 | #replaceKeyValue ${DOCKER_ENV_FILE} "USER_ID" "$(id -u $USER)" 571 | #replaceKeyValue ${DOCKER_ENV_FILE} "GROUP_ID" "$(id -g $USER)" 572 | 573 | ################################################### 574 | #### ---- Get "Key=Value" withe new value ---- 575 | #### Usage: getKeyValuePair 576 | #### Output: Key=Value 577 | ################################################### 578 | KeyValuePair="" 579 | function getKeyValuePair() { 580 | KeyValuePair="" 581 | inFile=${1:-${DOCKER_ENV_FILE}} 582 | keyLike=$2 583 | if [ "$2" == "" ]; then 584 | echo "**** ERROR: Empty Key value! Abort!" 585 | exit 1 586 | fi 587 | matchedKV=`grep -E "^[[:blank:]]*${keyLike}.+[[:blank:]]*=[[:blank:]]*.+[[:blank:]]*" ${DOCKER_ENV_FILE}` 588 | for kv in $matchedKV; do 589 | echo "KeyValuePair=${matchedKV// /}" 590 | done 591 | } 592 | #getKeyValuePair "${DOCKER_ENV_FILE}" "MYSQL_DATABASE" 593 | 594 | ## -- transform '-' and space to '_' 595 | #instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/\-: " "_"` 596 | instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/: " "_"` 597 | 598 | ################################################ 599 | ##### ---- Product Specific Parameters ---- #### 600 | ################################################ 601 | #MYSQL_DATABASE=${MYSQL_DATABASE:-myDB} 602 | #MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-password} 603 | #MYSQL_USER=${MYSQL_USER:-user1} 604 | #MYSQL_PASSWORD=${MYSQL_PASSWORD:-password} 605 | #### ---- Generate Env. Variables ---- 606 | echo ${ENV_VARS} 607 | 608 | echo "---------------------------------------------" 609 | echo "---- Starting a Container for ${imageTag}" 610 | echo "---------------------------------------------" 611 | 612 | cleanup 613 | 614 | ################################# 615 | ## -- USER_VARS into Docker -- ## 616 | ################################# 617 | if [ ${USER_VARS_NEEDED} -gt 0 ]; then 618 | USER_VARS="--user $(id -u $USER)" 619 | fi 620 | 621 | echo "--------------------------------------------------------" 622 | echo "==> Commands to manage Container:" 623 | echo "--------------------------------------------------------" 624 | echo " ./shell.sh : to shell into the container" 625 | echo " ./stop.sh : to stop the container" 626 | echo " ./log.sh : to show the docker run log" 627 | echo " ./build.sh : to build the container" 628 | echo " ./commit.sh: to push the container image to docker hub" 629 | echo "--------------------------------------------------------" 630 | 631 | ################################# 632 | ## ---- Setup X11 Display -_-- ## 633 | ################################# 634 | X11_OPTION= 635 | function setupDisplayType() { 636 | if [[ "$OSTYPE" == "linux-gnu" ]]; then 637 | # ... 638 | xhost +SI:localuser:$(id -un) 639 | xhost + 127.0.0.1 640 | echo ${DISPLAY} 641 | elif [[ "$OSTYPE" == "darwin"* ]]; then 642 | # Mac OSX 643 | # if you want to multi-media, you need customize it here 644 |        MEDIA_OPTIONS= 645 | xhost + 127.0.0.1 646 | export DISPLAY=host.docker.internal:0 647 | echo ${DISPLAY} 648 | elif [[ "$OSTYPE" == "cygwin" ]]; then 649 | # POSIX compatibility layer and Linux environment emulation for Windows 650 | xhost + 127.0.0.1 651 | echo ${DISPLAY} 652 | elif [[ "$OSTYPE" == "msys" ]]; then 653 | # Lightweight shell and GNU utilities compiled for Windows (part of MinGW) 654 | xhost + 127.0.0.1 655 | echo ${DISPLAY} 656 | elif [[ "$OSTYPE" == "freebsd"* ]]; then 657 | # ... 658 | xhost + 127.0.0.1 659 | echo ${DISPLAY} 660 | else 661 | # Unknown. 662 | echo "Unknown OS TYPE: $OSTYPE! Not supported!" 663 | exit 9 664 | fi 665 | echo "DISPLAY=${DISPLAY}" 666 | echo 667 | } 668 | 669 | 670 | ################################################## 671 | ## ---- Setup Corporate Chain's Certificates -- ## 672 | ################################################## 673 | CERTIFICATE_OPTIONS= 674 | function setupCorporateCertificates() { 675 | cert_dir=`pwd`/certificates 676 | if [ -d ./certificates/ ]; then 677 | CERTIFICATE_OPTIONS="${CERTIFICATE_OPTIONS} -v ${cert_dir}:/certificates" 678 | fi 679 | echo "CERTIFICATE_OPTIONS=${CERTIFICATE_OPTIONS}" 680 | } 681 | setupCorporateCertificates 682 | 683 | 684 | ################################################## 685 | ## ---- Setup accessing HOST's /etc/hosts: ---- ## 686 | ################################################## 687 | ## **************** WARNING: ********************* 688 | ## **************** WARNING: ********************* 689 | ## **************** WARNING: ********************* 690 | # => this might open up more attack surface since 691 | # /etc/hosts has other nodes IP/name information 692 | # ------------------------------------------------ 693 | HOSTS_OPTIONS="-v /etc/hosts:/etc/hosts" 694 | 695 | 696 | ################################################## 697 | ################################################## 698 | ## ----------------- main --------------------- ## 699 | ################################################## 700 | ################################################## 701 | 702 | case "${BUILD_TYPE}" in 703 | 0) 704 | #### 0: (default) has neither X11 nor VNC/noVNC container build image type 705 | #### ---- for headless-based / GUI-less ---- #### 706 | MORE_OPTIONS="${MORE_OPTIONS} ${HOSTS_OPTIONS} " 707 | sudo docker run \ 708 | --name=${instanceName} \ 709 | --restart=${RESTART_OPTION} \ 710 | ${REMOVE_OPTION} ${RUN_OPTION} ${MORE_OPTIONS} ${CERTIFICATE_OPTIONS} \ 711 | ${privilegedString} \ 712 | ${USER_VARS} \ 713 | ${ENV_VARS} \ 714 | ${VOLUME_MAP} \ 715 | ${PORT_MAP} \ 716 | ${imageTag} \ 717 | $* 718 | ;; 719 | 1) 720 | #### 1: X11/Desktip container build image type 721 | #### ---- for X11-based ---- #### 722 | setupDisplayType 723 | echo ${DISPLAY} 724 | #X11_OPTION="-e DISPLAY=$DISPLAY -v $HOME/.chrome:/data -v /dev/shm:/dev/shm -v /tmp/.X11-unix:/tmp/.X11-unix -e DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket" 725 | X11_OPTION="-e DISPLAY=$DISPLAY -v /dev/shm:/dev/shm -v /tmp/.X11-unix:/tmp/.X11-unix " 726 | echo "X11_OPTION=${X11_OPTION}" 727 | MORE_OPTIONS="${MORE_OPTIONS} ${HOSTS_OPTIONS} " 728 | sudo docker run \ 729 | --name=${instanceName} \ 730 | --restart=${RESTART_OPTION} \ 731 | ${REMOVE_OPTION} ${RUN_OPTION} ${MORE_OPTIONS} ${CERTIFICATE_OPTIONS} \ 732 | ${X11_OPTION} ${MEDIA_OPTIONS} \ 733 | ${privilegedString} \ 734 | ${USER_VARS} \ 735 | ${ENV_VARS} \ 736 | ${VOLUME_MAP} \ 737 | ${PORT_MAP} \ 738 | ${imageTag} \ 739 | $* 740 | ;; 741 | 2) 742 | #### 2: VNC/noVNC container build image type 743 | #### ----------------------------------- #### 744 | #### -- VNC_RESOLUTION setup default --- #### 745 | #### ----------------------------------- #### 746 | if [ "`echo $ENV_VARS|grep VNC_RESOLUTION`" = "" ]; then 747 | #VNC_RESOLUTION=1280x1024 748 | VNC_RESOLUTION=1920x1080 749 | ENV_VARS="${ENV_VARS} -e VNC_RESOLUTION=${VNC_RESOLUTION}" 750 | fi 751 | MORE_OPTIONS="${MORE_OPTIONS} ${HOSTS_OPTIONS} " 752 | sudo docker run \ 753 | --name=${instanceName} \ 754 | --restart=${RESTART_OPTION} \ 755 | ${REMOVE_OPTION} ${RUN_OPTION} ${MORE_OPTIONS} ${CERTIFICATE_OPTIONS} \ 756 | ${privilegedString} \ 757 | ${USER_VARS} \ 758 | ${ENV_VARS} \ 759 | ${VOLUME_MAP} \ 760 | ${PORT_MAP} \ 761 | ${imageTag} \ 762 | $* 763 | ;; 764 | 765 | esac 766 | 767 | 768 | -------------------------------------------------------------------------------- /save.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | MY_DIR=$(dirname "$(readlink -f "$0")") 4 | 5 | if [ $# -lt 1 ]; then 6 | echo "Usage: " 7 | echo " ${0} " 8 | echo "e.g.: " 9 | echo " ${0} " 10 | fi 11 | 12 | ################################################### 13 | #### ---- Change this only to use your own ---- 14 | ################################################### 15 | ORGANIZATION=openkbs 16 | 17 | ################################################### 18 | #### **** Container package information **** 19 | ################################################### 20 | DOCKER_IMAGE_REPO=`echo $(basename $PWD)|tr '[:upper:]' '[:lower:]'|tr "/: " "_" ` 21 | imageTag="${ORGANIZATION}/${DOCKER_IMAGE_REPO}" 22 | imageTag=${1:-$imageTag} 23 | 24 | IMAGE_NAME=${imageTag%:*} 25 | IMAGE_VERSION=${imageTag#*:} 26 | if [ "$IMAGE_VERSION" = "" ]; then 27 | # -- patch in the image version 28 | imageTag="${IMAGE_NAME}:latest" 29 | fi 30 | ################################################### 31 | #### ---- Mostly, you don't need change below ---- 32 | ################################################### 33 | ## -- transform '-' and space to '_' 34 | #instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/\-: " "_"` 35 | instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/: " "_"` 36 | 37 | TGZ_DOCKER_IMAGE=${instanceName}.tgz 38 | 39 | function save() { 40 | lookupImage=`sudo docker images ${imageTag} | grep ${imageTag} | awk '{print $1}'` 41 | if [ "$lookupImage" = "" ]; then 42 | echo "*** ERROR ***: Can't find Docker image (${imageTag}): Can't continue! Abort!" 43 | exit 1 44 | fi 45 | sudo docker save ${imageTag} | gzip > ${TGZ_DOCKER_IMAGE} 46 | ls -al ${TGZ_DOCKER_IMAGE} 47 | } 48 | 49 | echo "---------------------------------------------" 50 | echo "---- SAVE a Container for ${imageTag}" 51 | echo "---------------------------------------------" 52 | 53 | save 54 | 55 | 56 | -------------------------------------------------------------------------------- /shell.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | MY_DIR=$(dirname "$(readlink -f "$0")") 4 | 5 | if [ $# -lt 1 ]; then 6 | echo "Usage: " 7 | echo " ${0} " 8 | echo "e.g.: " 9 | echo " ${0} ls -al " 10 | fi 11 | 12 | ################################################### 13 | #### ---- Change this only to use your own ---- 14 | ################################################### 15 | ORGANIZATION=openkbs 16 | baseDataFolder="$HOME/data-docker" 17 | 18 | ################################################### 19 | #### **** Container package information **** 20 | ################################################### 21 | DOCKER_IMAGE_REPO=`echo $(basename $PWD)|tr '[:upper:]' '[:lower:]'|tr "/: " "_" ` 22 | imageTag="${ORGANIZATION}/${DOCKER_IMAGE_REPO}" 23 | 24 | ## -- transform '-' and space to '_' 25 | #instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/\-: " "_"` 26 | instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/: " "_"` 27 | 28 | echo "---------------------------------------------" 29 | echo "---- shell into the Container for ${imageTag}" 30 | echo "---------------------------------------------" 31 | 32 | sudo docker exec -it $(sudo docker ps -a |grep ${instanceName} |awk '{print $1;}') /bin/bash 33 | 34 | -------------------------------------------------------------------------------- /stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | MY_DIR=$(dirname "$(readlink -f "$0")") 4 | 5 | if [ $# -lt 1 ]; then 6 | echo "Usage: " 7 | echo " ${0} " 8 | echo "e.g.: " 9 | echo " ${0} ls -al " 10 | fi 11 | 12 | ################################################### 13 | #### ---- Change this only to use your own ---- 14 | ################################################### 15 | ORGANIZATION=openkbs 16 | baseDataFolder="$HOME/data-docker" 17 | 18 | ################################################### 19 | #### **** Container package information **** 20 | ################################################### 21 | DOCKER_IMAGE_REPO=`echo $(basename $PWD)|tr '[:upper:]' '[:lower:]'|tr "/: " "_" ` 22 | imageTag="${ORGANIZATION}/${DOCKER_IMAGE_REPO}" 23 | 24 | ################################################### 25 | #### ---- Mostly, you don't need change below ---- 26 | ################################################### 27 | function cleanup() { 28 | containerID=`sudo docker ps -a|grep "${instanceName}" | awk '{print $1}'` 29 | # if [ ! "`sudo docker ps -a|grep ${instanceName}`" == "" ]; then 30 | if [ "${containerID}" != "" ]; then 31 | sudo docker rm -f ${containerID} 32 | fi 33 | } 34 | 35 | ## -- transform '-' and space to '_' 36 | #instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/\-: " "_"` 37 | instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/: " "_"` 38 | 39 | echo "---------------------------------------------" 40 | echo "---- stop a Container for ${imageTag}" 41 | echo "---------------------------------------------" 42 | 43 | cleanup 44 | 45 | 46 | --------------------------------------------------------------------------------