docker-compose args from shell

前端 未结 3 2205
醉酒成梦
醉酒成梦 2021-02-14 19:04

I want to build via the docker-compose an image that uses my private key for cloning private git repos.

More or less the compose becomes as fol

3条回答
  •  春和景丽
    2021-02-14 19:30

    One way to do it that will work when building all the services and also with up is to pass the SSH key data as an environnement variable like this:

    env RSA=$(cat ~/.ssh/id_rsa) docker-compose build
    

    And then you set the build args in the compose file like this:

    myservice:
     build:
      context: .
      args:
        RSA: |-
          ${RSA}
    

提交回复
热议问题