[英]Spring Boot Cloud Configuration, GitLab, Docker and SSH Key Set Up
I am attempting to use to build a Spring Cloud application that utilizes a repository hosted on GitLab to store configuration details.我正在尝试构建一个 Spring Cloud 应用程序,该应用程序利用托管在 GitLab 上的存储库来存储配置详细信息。 I can run it on my local machine.
我可以在我的本地机器上运行它。 However, I am struggling to place it in a container due to the need for SSH keys.
但是,由于需要 SSH 密钥,我正在努力将其放入容器中。 For example, my application.properties files for the configuration server:
例如,我的配置服务器的 application.properties 文件:
server.port=8888
spring.cloud.config.server.git.uri=git@gitlab.com:repo
I have referenced this StackOverflow question ;我已经参考了这个StackOverflow 问题; however, I am using a docker-compose file.
但是,我使用的是 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:
Is there anyway to access a private git repo from docker containers when a compose file is used?无论如何,当使用撰写文件时,是否可以从 docker 容器访问私有 git 存储库? Thanks.
谢谢。
Two steps to resolve this problem:解决这个问题的两个步骤:
Generate a SSH key file in the local machine which the docker container will run at在本地机器上生成一个 SSH 密钥文件,docker 容器将在该文件中运行
Modify the docker-composer file to add a volume option to mapping the .ssh folder from the local machine to docker container.修改 docker-composer 文件,添加一个 volume 选项,将 .ssh 文件夹从本地机器映射到 docker 容器。
config: image: kellymarchewa/config_server volumes: - /root/.ssh:/root/.ssh networks: - app restart: always
Hop this can resolve your problem, if you have any issue, you can contract me.跳这可以解决您的问题,如果您有任何问题,可以与我联系。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.