0

Currently, my docker-compose.yml is building an image. I have an image from a 3rd party that I need to add alongside my own, which my own image will be dependent on. When running the 3rd party image independently, I need to pass an argument to it like this:

docker run third_party/image --argument_flag

How do I translate this into the docker-compose.yml so that the argument_flag gets passed. Here is my yml (names have been generalized).

version: '3'
services:
  my_app:
    build: .
    volumes:
      - .:/my_app_folder
    depends_on: 
      - "third_party"
  third_party:
    image: third_party/image
    ports:
      - "8050:8050"
Matt McNair
  • 21
  • 1
  • 1

3 Answers3

2

You can pass your argument by overriding the default command

shyam
  • 9,134
  • 4
  • 29
  • 44
0

In Dockerfile you can get the argument ARGUMENT:

docker-compose build --build-arg PRODUCTION=VALUE

Dockerfile:

ARG ARGUMENT
FROM node:latest

or try to check it out: How to pass arguments within docker-compose? seems like the answer has been already there

Vova
  • 3,117
  • 2
  • 15
  • 23
-2

In docker-compose file you can add like this. 'args' tag in docker-compose file represent the argument same as docker run.

  third_party:
    image: third_party/image
    args:
       some_variable_name: some_value
    ports:
      - "8050:8050"
Sounak Saha
  • 852
  • 1
  • 9
  • 21