我正在尝试在Docker容器上启动Spring Cloud Config Server,并且遇到了无效远程异常。阅读日志,似乎Docker容器无权访问Volume,但我不确定。我正在使用CentO。任何建议都会受到赞赏。
Dockerfile
FROM openjdk:8-jdk-alpine
MAINTAINER jimis.drpc@gmail.com
COPY files/config-server-0.0.1-SNAPSHOT.jar /opt/spring-cloud/lib/
ENV SPRING_APPLICATION_JSON='{"spring": {"cloud": {"config": {"server": {"git": {"uri": "/var/lib/spring-cloud/config-repo", "clone-on-start": true}}}}}}'
ENTRYPOINT ["/usr/bin/java"]
CMD ["-jar", "/opt/spring-cloud/lib/config-server-0.0.1-SNAPSHOT.jar"]
VOLUME /var/lib/spring-cloud/config-repo
EXPOSE 8888
Spring Boot application.properties
server.port=8888
management.security.enabled=true
spring.autoconfigure.exclude=org.springframawork.boot.autoconfigure.SecurityAutoConfiguration
日志:
test]$ docker build --no-cache --file=Dockerfile --tag=config-server:latest --rm=true .
Sending build context to Docker daemon 30.3MB
Step 1/8 : FROM openjdk:8-jdk-alpine
---> 88d1c219f815
Step 2/8 : MAINTAINER jimis.drpc@gmail.com
---> Running in a204b40b9f04
Removing intermediate container a204b40b9f04
---> 456dacbfaefa
Step 3/8 : COPY files/config-server-0.0.1-SNAPSHOT.jar /opt/spring-cloud/lib/
---> 55d1d05d4999
Step 4/8 : ENV SPRING_APPLICATION_JSON='{"spring": {"cloud": {"config": {"server": {"git": {"uri": "/var/lib/spring-cloud/config-repo", "clone-on-start": true}}}}}}'
---> Running in 5036de819188
Removing intermediate container 5036de819188
---> dfecf1c03d37
Step 5/8 : ENTRYPOINT ["/usr/bin/java"]
---> Running in bfbbe5d1ec20
Removing intermediate container bfbbe5d1ec20
---> 9395dc9a8c81
Step 6/8 : CMD ["-jar", "/opt/spring-cloud/lib/config-server-0.0.1-SNAPSHOT.jar"]
---> Running in 0f5bc5285e8b
Removing intermediate container 0f5bc5285e8b
---> fc8e287837e7
Step 7/8 : VOLUME /var/lib/spring-cloud/config-repo
---> Running in 9125b1dcd48e
Removing intermediate container 9125b1dcd48e
---> 780c5215f875
Step 8/8 : EXPOSE 8888
---> Running in 7e752e7e84be
Removing intermediate container 7e752e7e84be
---> 8a664539c179
Successfully built 8a664539c179
Successfully tagged config-server:latest
[jimis@bv-vpc-1097 test]$ docker volume create --name=spring-cloud-config-repo
spring-cloud-config-repo
[jimis@bv-vpc-1097 test]$ docker run --name=config-server --publish=8888:8888 --volume=spring-cloud-config-repo:/var/lib/spring-cloud/config-repo config-server:latest
2019-04-11 16:22:17.683 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$9b802ec4] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.3.RELEASE)
2019-04-11 16:22:17.983 INFO 1 --- [ main] c.m.c.ConfigServerApplication : No active profile set, falling back to default profiles: default
2019-04-11 16:22:19.548 INFO 1 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=11be5ef3-61b1-3539-a246-b6326ba4f12c
2019-04-11 16:22:19.631 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$9b802ec4] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-04-11 16:22:20.199 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8888 (http)
2019-04-11 16:22:20.250 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-04-11 16:22:20.251 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.16]
2019-04-11 16:22:20.269 INFO 1 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64:/usr/lib/jvm/java-1.8-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2019-04-11 16:22:20.561 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-04-11 16:22:20.561 INFO 1 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2551 ms
2019-04-11 16:22:21.652 WARN 1 --- [ main] .c.s.e.MultipleJGitEnvironmentRepository : Error occured cloning to base directory.
org.eclipse.jgit.api.errors.InvalidRemoteException: Invalid remote: origin
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:251) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar!/:5.1.3.201810200350-r]
at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:306) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar!/:5.1.3.201810200350-r]
at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:200) ~[org.eclipse.jgit-5.1.3.201810200350-r.jar!/:5.1.3.201810200350-r]
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.cloneToBasedir(JGitEnvironmentRepository.java:589) [spring-cloud-config-server-2.1.1.RELEASE.jar!/:2.1.1.RELEASE]