Pass a variable to a Dockerfile from a docker-compose.yml file

前端 未结 1 509
失恋的感觉
失恋的感觉 2020-12-20 11:21

I have several docker-compose.yml files that I want to use the same Dockerfile with, with a slight variation. So I want to pass an argument to that Dockerfile so that I can

相关标签:
1条回答
  • 2020-12-20 11:40

    Basically I missed declaring the arg in the Dockerfile.

    # docker-compose.yml file
    
    version: '2'
    
    services:
      django:
        build:
          context: .
          dockerfile: ./docker/Dockerfile
          args:
            - SOMETHING=foo
    

     

    # Dockerfile
    ARG SOMETHING
    RUN echo $SOMETHING
    


    Shoutout to @Lauri for showing me the light.

    0 讨论(0)
提交回复
热议问题