[英]Docker not catching env vars
I'm trying to run 3 containers through docker-compose, with postgres, cassandra and my webapp, wich has a embedded tomcat server with some dependencies as ARP/Native. 我试图通过docker-compose运行3个容器,使用postgres,cassandra和我的webapp,它有一个嵌入式tomcat服务器,有一些依赖关系作为ARP / Native。 This libraries are located in a folder called "lib" at jar's same level.
这个库位于jar级别的名为“lib”的文件夹中。
I'm running a PoC on Windows 10 (using linux containers) before moving it to a CentOS server, if it works on the PoC. 我在Windows 10上运行PoC(使用Linux容器),然后将其移动到CentOS服务器,如果它在PoC上运行的话。 I searched over the net and seems like is not an isolated problem but or i have no find the solution, or the solution showed didnt work for me.
我在网上搜索,似乎不是一个孤立的问题,但或者我找不到解决方案,或者解决方案显示我没有工作。 Here is my docker-compose.yml, with all the related files/folders storaged at same level:
这是我的docker-compose.yml,所有相关的文件/文件夹都存放在同一级别:
version: '3.1'
services:
fulmar-webapp:
container_name: "my-webapp"
image: openjdk:11-jre-slim
hostname: mywebapp
volumes:
- ./lib:/home/lib
- ./fulmar-1.0.1-SNAPSHOT-exec.jar:/home/mywebapp-1.0.1-SNAPSHOT-exec.jar
entrypoint:
- java
- -jar
- /home/mywebapp-1.0.1-SNAPSHOT-exec.jar
environment:
- LD_LIBRARY_PATH:/home/lib
- spring.datasource.url=jdbc:postgresql://postgresql:5432/mydb
- spring.datasource.username=postgres
- spring.datasource.password=postgres
- spring.jpa.hibernate.ddlAuto=update
network_mode: bridge
ports:
- 8443:8443
- 8080:8080
links:
- postgresql
- cassandra
postgresql:
container_name: "mydb"
image: postgres:11.1-alpine
restart: always
environment:
POSTGRES_DB: mydb
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
volumes:
- ./startup.sql:/docker-entrypoint-initdb.d/startup.sql
- postgresdata:/var/lib/postgresql/data
ports:
- 5432:5432
network_mode: bridge
cassandra:
container_name: "cassandra"
image: cassandra
ports:
- 9042:9042
network_mode: bridge
volumes: postgresdata: 卷:postgresdata:
Not sure if is not properly mapping the folder with the libraries, or is not actually mounting the volume. 不确定是否未正确映射文件夹与库,或实际上没有安装卷。 This is exactly the Enviroment var I need to put in there: Environment=LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/libraries/lib
这正是我需要放入的Enviroment var:Environment = LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/ path / to / libraries / lib
Two results I have encountered: 我遇到的两个结果:
1-Tomcat exception cause it can not find the libraries: 1-Tomcat异常导致它无法找到库:
[ERROR][org.apache.catalina.util.LifecycleBase#log(175)] Failed to
initialize component [Connector[org.apache.coyote.http11.Http11AprProtocol-
8080]] | org.apache.catalina.LifecycleException: The configured protocol
[org.apache.coyote.http11.Http11AprProtocol] requires the APR/native library
which is not available
2-WARNING: The LD_LIBRARY_PATH variable is not set. 2-WARNING:未设置LD_LIBRARY_PATH变量。 Defaulting to a blank string.
默认为空字符串。
Thanks you all in advance 提前谢谢大家
EDIT: just let you know the once i run docker-compose up, and my app throws this exception, the container is no longer available so i'm unable to run any commands in it 编辑:只是让你知道,一旦我运行docker-compose,我的应用程序抛出此异常,容器不再可用,所以我无法在其中运行任何命令
You have a wrong syntax, it should be like this: 你的语法错误,它应该是这样的:
environment:
- LD_LIBRARY_PATH=/home/lib
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.