我想知道在工作站上运行 Che 时使用自定义 Eclipse Che 堆栈的便捷方法是什么。
我真的很喜欢 Eclipse Che 的概念:为不同的开发环境提供单独的 Che 工作区(Docker 容器),并安装相应的工具。工作区从 Che 堆栈初始化。堆栈可以定义为 Docker 镜像,也可以使用 Dockerfiles 或 Docker composer 文件动态创建。
我想达到什么目标:
我已经尝试过:
1. 按配方定义堆栈(Dockerfile)
FROM eclipse/stack-base:ubuntu
RUN sudo apt-get update
RUN sudo apt-get install -y apt-transport-https
RUN sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
RUN sudo apt-get install -y nodejs build-essential mongodb-org
RUN sudo apt-get clean
RUN sudo apt-get -y autoremove
RUN sudo apt-get -y clean
RUN sudo rm -rf /var/lib/apt/lists/*
它基于
eclipse/stack-base:ubuntu
docs 中建议的图像这种方法有一个明显的缺点:在我的工作站重新启动后,Che 会从 Dockerfile 重建工作区!只要 Dockerfile 包含安装命令,该过程就会花费大量时间,并且显然需要互联网连接。
2. 基于本地Docker镜像的堆栈
sudo docker build -f custom.dockerfile -t my-custom-image .
{
"scope": "general",
"description": "Custom1",
"tags": [],
"workspaceConfig": {
"environments": {
"default": {
"recipe": {
"contentType": "text/x-dockerfile",
"type": "dockerfile",
"content": "FROM my-custom-image\n"
},
"machines": {
"dev-machine": {
"servers": {},
"agents": [
"org.eclipse.che.ws-agent",
"org.eclipse.che.ssh",
"org.eclipse.che.terminal",
"org.eclipse.che.exec"
],
"attributes": {
"memoryLimitBytes": "2147483648"
}
}
}
}
},
"defaultEnv": "default",
"commands": [],
"projects": [],
"name": "default",
"links": []
},
"components": [],
"creator": "che",
"name": "my-custom-1",
"id": "stackx6hs410a9awhu299"
}
{
"scope": "general",
"description": "Custom2",
"tags": [],
"workspaceConfig": {
"environments": {
"default": {
"recipe": {
"contentType": "application/x-yaml",
"type": "compose",
"content": "services:\n dev-machine:\n image: my-custom-image\n"
},
"machines": {
"dev-machine": {
"servers": {},
"agents": [
"org.eclipse.che.exec",
"org.eclipse.che.terminal",
"org.eclipse.che.ws-agent",
"org.eclipse.che.ssh"
],
"attributes": {
"memoryLimitBytes": "2147483648"
}
}
}
}
},
"defaultEnv": "default",
"commands": [],
"projects": [],
"name": "custom",
"links": []
},
"components": [],
"creator": "che",
"name": "my-custom-2",
"id": "stack55s3tso56cljsf30"
}
Could not start workspace my-custom-1. Reason: Start of environment 'default' failed. Error: Docker image build failed. Image id not found in build output.
Could not start workspace my-custom-2. Reason: Start of environment 'default' failed. Error: Can't create machine from image. Cause: Error response from docker API, status: 404, message: repository my-node-mongo not found: does not exist or no pull access
看起来 Che 在我的工作站上没有看到 Docker 图像。
所以问题是:有没有什么办法可以让车实现我的目标?还是 Che 不适合我?
更新 1
3. 设置本地 docker 注册表 ( https://docs.docker.com/registry/ )
sudo docker build -f custom.dockerfile -t my-custom-image .
sudo docker tag my-custom-image localhost:5000/my-custom-image
sudo docker push localhost:5000/my-custom-image
localhost:5000/my-custom-image
这种方法有效,但有明确的 缺点:必须维护 docker 注册表 .
无论如何它都有效,我可以在我的愿望 list 中勾选两个复选框。
最佳答案
如果要使用本地镜像,设置 CHE_DOCKER_ALWAYS__PULL__IMAGE=false
在您的 che.env 中并重新启动 Che。
关于eclipse-che - 如何在工作站主机上使用自定义 Eclipse Che 堆栈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47919884/