我想定义一个包含命名参数和位置参数的Apache Commons CLI解析器.
program [-a optA] [-b optB] [-f] pos1 pos2
Run Code Online (Sandbox Code Playgroud)
如何验证pos1和pos2?
我正在尝试使用以下 Dockerfile 在 Docker 容器中创建一个 postgres 实例。
FROM postgres
ENV POSTGRES_DB dspace
ENV POSTGRES_USER dspace
ENV POSTGRES_PASSWORD dspace
COPY init.sql /docker-entrypoint-initdb.d/
Run Code Online (Sandbox Code Playgroud)
这是我的 init.sql
create extension pgcrpyto
Run Code Online (Sandbox Code Playgroud)
我正在使用 Codenvy 服务来运行这个容器。初始化时,我看到以下错误。
[STDOUT] server started
[STDOUT] Reading package lists...
[STDOUT] Reading package lists...
[STDOUT] Building dependency tree...
[STDOUT] CREATE DATABASE
[STDOUT]
[STDOUT] CREATE ROLE
[STDOUT]
[STDOUT]
[STDOUT] /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/init.sql
[STDOUT] Reading state information...
[STDOUT] 2018-02-15 19:17:34.931 UTC [399] ERROR: could not open extension control file "/usr/share/postgresql/10/extension/pgcrpyto.control": No such file or directory
[STDOUT] …
Run Code Online (Sandbox Code Playgroud) 我想在 docker-compose yaml 文件中嵌入 HEREDOC。
version: "3.7"
services:
test-cli:
image: ubuntu
entrypoint: |
/bin/sh << HERE
echo hello
echo goodbye
HERE
Run Code Online (Sandbox Code Playgroud)
当我尝试运行此程序时,出现以下错误。
docker-compose -f heredoc.yml run --rm test-cli
Creating network "dspace-compose-v2_default" with the default driver
/bin/sh: 0: Can't open <<
Run Code Online (Sandbox Code Playgroud) 作为我的DSpace实例的一部分,我有一个包含1200万使用情况统计记录的SOLR存储库.某些记录已通过多个SOLR升级进行迁移,并且不符合当前架构.其中500万条记录缺少我的架构中指定的唯一ID字段.
DSpace系统提供了一种机制,可使用以下代码将较旧的使用情况统计信息记录分片到单独的solr分片中.
DSPACE SHARD LOGIC:
for (File tempCsv : filesToUpload) {
//Upload the data in the csv files to our new solr core
ContentStreamUpdateRequest contentStreamUpdateRequest = new ContentStreamUpdateRequest("/update/csv");
contentStreamUpdateRequest.setParam("stream.contentType", "text/plain;charset=utf-8");
contentStreamUpdateRequest.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
contentStreamUpdateRequest.addFile(tempCsv, "text/plain;charset=utf-8");
statisticsYearServer.request(contentStreamUpdateRequest);
}
statisticsYearServer.commit(true, true);
Run Code Online (Sandbox Code Playgroud)
当我尝试运行此过程时,我收到了一条错误消息,指出我的每条记录都缺少唯一的id字段,并且该过程丢弃了500万条记录.
我试图替换这500万条记录,以强制在每条记录上创建唯一的id字段.这是我正在运行以触发该更新的代码.查询myQuery迭代数千条记录的批次.
我的录音修复程序:
ArrayList<SolrInputDocument> idocs = new ArrayList<SolrInputDocument>();
SolrQuery sq = new SolrQuery();
sq.setQuery(myQuery);
sq.setRows(MAX);
sq.setSort("time", ORDER.asc);
QueryResponse resp = server.query(sq);
SolrDocumentList list = resp.getResults();
if (list.size() > 0) {
for(int i=0; i<list.size(); i++) {
SolrDocument doc = list.get(i);
SolrInputDocument idoc …
Run Code Online (Sandbox Code Playgroud) 我已经对我工作的旧系统进行了docker化。我有一个 docker compose 文件,它引用了一个构建在 postgres 上的图像和一个构建在 tomcat 上的图像。此撰写文件适用于启动和停止应用程序的测试版本。
services:
db:
image: mypostgres
container_name: db
networks:
- mynetwork
tomcat:
image: mytomcat
container_name: tomcat
networks:
- mynetwork
environment:
- myhost=localhost
volumes:
- "mydata:/mydata"
depends_on:
- db
Run Code Online (Sandbox Code Playgroud)
我想在系统上执行一些额外的命令行任务。其中一些任务是计算密集型的。这些任务对 mydata 卷中的文件进行操作。
目前,我使用以下命令在 tomcat 容器中运行此任务。
docker exec tomcat /bin/my-script.sh param
Run Code Online (Sandbox Code Playgroud)
我认为创建一个单独的容器来运行这个任务是有意义的。如果我将其定义为服务,它将如下所示。
mycli:
image: mytomcat
networks:
- mynetwork
environment:
- myhost=tomcat
volumes:
- "mydata:/mydata"
depends_on:
- db
- mycli
entrypoint: /bin/myscript.sh
command:
- param
Run Code Online (Sandbox Code Playgroud)
这种配置的最佳实践是什么?
我有一个使用 docker-compose 测试的 tomcat + postgres 应用程序。我正在尝试将应用程序打包到 kubernetes 配置文件中。
现在,我正在使用我的 Docker Desktop for Windows 安装运行 kubernetes(和 kubectl)。最终,我想部署到其他环境。
我目前正在尝试在以下配置文件中复制 docker-compose 中的一些卷功能。
apiVersion: v1
kind: Pod
metadata:
name: pg-pod
spec:
volumes:
- name: "pgdata-vol"
#emptyDir: {}
hostPath:
path: /c/temp/vols/pgdata
containers:
- image: postgres
name: db
ports:
- containerPort: 5432
name: http
protocol: TCP
volumeMounts:
- mountPath: "/pgdata"
name: "pgdata-vol"
env:
- name: PGDATA
value: /pgdata
Run Code Online (Sandbox Code Playgroud)
当 postgres 启动时,我看到以下错误。
fixing permissions on existing directory /pgdata ... ok
creating subdirectories ... ok
selecting default …
Run Code Online (Sandbox Code Playgroud) Python 和 Ruby 有非常好的库用于将 Yaml 文件解析为 JSON 对象。
解析器需要支持 Yaml Anchor 和 References。
输入
info: &info
legs: 4 legs
type: pet
dog: *info
cat: *info
Run Code Online (Sandbox Code Playgroud)
期望的输出:
{
"info": {
"legs": "4 legs",
"type": "pet"
},
"dog": {
"legs": "4 legs",
"type": "pet"
},
"cat": {
"legs": "4 legs",
"type": "pet"
}
}
Run Code Online (Sandbox Code Playgroud)
我首先尝试了 Jackson YAMLFactory。该库一般不支持锚点和引用。
Java中有什么好的解决方案可以将Yaml解析为JSON对象?
我想构建一个 minio docker 容器用于集成测试目的。
我想在我的 Dockerfile 中执行以下操作。
测试数据
./test-data/foo.txt
./test-data/bar.txt
Run Code Online (Sandbox Code Playgroud)
FROM minio/minio
RUN mkdir -p /buckets/my-bucket
COPY test-data /buckets/my-bucket/test-data"
EXPOSE 9000 9001
CMD [ "minio", "server", "/buckets", "--address", ":9000", "--console-address", ":9001" ]
Run Code Online (Sandbox Code Playgroud)
我知道我可以mc
在一个单独的容器中运行来填充我的存储桶,但这需要一些编排。
有没有办法可以在 Dockerfile 中完成这些步骤?
docker ×3
yaml ×2
codenvy ×1
dspace ×1
heredoc ×1
java ×1
kubernetes ×1
minio ×1
postgresql ×1
solr ×1