[英]Spring Boot Cloud Configuration, GitLab, Docker and SSH Key Set Up
我正在尝试构建一个 Spring Cloud 应用程序,该应用程序利用托管在 GitLab 上的存储库来存储配置详细信息。 我可以在我的本地机器上运行它。 但是,由于需要 SSH 密钥,我正在努力将其放入容器中。 例如,我的配置服务器的 application.properties 文件:
server.port=8888
spring.cloud.config.server.git.uri=git@gitlab.com:repo
我已经参考了这个StackOverflow 问题; 但是,我使用的是 docker-compose 文件。
# Use postgres/example user/password credentials
version: '3.2'
services:
db:
image: postgres
ports:
- 5000:5432
environment:
POSTGRES_PASSWORD: example
volumes:
- type: volume
source: psql_data
target: /var/lib/postgresql/data
networks:
- app
restart: always
config:
image: kellymarchewa/config_server
networks:
- app
restart: always
search:
image: kellymarchewa/search_api
networks:
- app
restart: always
ports:
- 8081:8081
depends_on:
- db
- config
- inventory
inventory:
image: kellymarchewa/inventory_api
depends_on:
- db
- config
ports:
- 8080:8080
networks:
- app
restart: always
volumes:
psql_data:
networks:
app:
无论如何,当使用撰写文件时,是否可以从 docker 容器访问私有 git 存储库? 谢谢。
解决这个问题的两个步骤:
在本地机器上生成一个 SSH 密钥文件,docker 容器将在该文件中运行
修改 docker-composer 文件,添加一个 volume 选项,将 .ssh 文件夹从本地机器映射到 docker 容器。
config: image: kellymarchewa/config_server volumes: - /root/.ssh:/root/.ssh networks: - app restart: always
跳这可以解决您的问题,如果您有任何问题,可以与我联系。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.