I've made the following Dockerfile:
FROM python:3.7
WORKDIR /app
# Install python dependencies
ADD requirements.txt /app/
RUN pip3 install --upgrade pip
RUN pip3 install -r requirements.txt
# Copy sources
ADD . /app
# Read arguments
ARG top_k=5
ARG threshold=0.5
ARG broker=broker.mqttdashboard.com
ARG port=8000
ARG topic=topic/truc
# Run detection
CMD python3 detect.py --top_k ${top_k} --threshold ${threshold} --broker ${broker} --port ${port} --topic ${topic}
The building works great but when I try to run the container, I got an error saying the arguments are missing:
usage: detect.py [-h] [--top_k TOP_K] [--threshold THRESHOLD]
[--broker BROKER] [--port PORT] [--topic TOPIC]
detect.py: error: argument --top_k: expected one argument
The python code is very basic:
parser = argparse.ArgumentParser()
parser.add_argument('--top_k', type=int, default=3, help='Number of categories with highest score to display')
args = parser.parse_args()
Is there something I don't understand with Docker ARG ?
My plan is to edit these arguments in the kubernetes yaml file.
ARGis intended for within Dockerfile only. See Understand how ARG and FROM interact.