how to pass argument using Azure Container Instance Command Override??
Ahmad Shafiq
125
Reputation points
I have a docker image locally that works fine when I run it with the following command
"docker run --name scrapper-container image-name:tag state-scrapper.py"
but when I run this inside azure container instance using command over ride and write this
["state-scrapper.py"] it first continuously fail the container and the error message is
Error: Failed to start container scrapper-container, Error response: to create containerd task: failed to create shim task: failed to create container : guest RPC failure: failed to create container: failed to run runc create/exec call for container with exit status 1: container_linux.go:380: starting container process caused: exec: "state-scrapper.py": executable file not found in $PATH: unknown | |
---|---|
after this i just provide the full path of the script file that have to run inside the container using ["/app/state-scrapper.py"] in command override option it started the container but in logs i have found this error |
standard_init_linux.go:228: exec user process caused: exec format error
I have attcehed my dockerfile
# Use an official Python runtime as a parent image
FROM selenium/standalone-chrome:112.0 as build
# isntalling `xvfb` is required for headfull Chrome; it's the virtual screen
RUN sudo apt update && sudo apt install -y python3-pip xvfb && sudo apt upgrade -y
# this line is just for Python
ENV PYTHONUNBUFFERED=1
# required for headfull Chrome
ENV DISPLAY=:0
# Set the working directory in the container
WORKDIR /app
#state Scrapper
COPY state-scrapper.py /app
COPY state-urls.txt /app
COPY ./chromedriver/Linux/112/chromedriver ./lib/chromedriver/Linux/112/chromedriver
COPY --chmod=+x entrypoint.sh /app
RUN pip install --no-cache-dir --upgrade pip
# Install Python dependencies
RUN pip install --no-cache-dir azure-storage-blob requests beautifulsoup4 selenium python-dotenv webdriver_manager lxml azure-search-documents azure-core
ENTRYPOINT ["/app/entrypoint.sh"]
and my enterypoint.sh is as follow
#!/bin/bash
# Check if a script name is provided
if [ -z "$1" ]; then
echo "No scraper script provided. Exiting."
exit 1
fi
# Check if the specified script exists
if [ ! -f "/app/$1" ]; then
echo "Script /app/$1 not found. Exiting."
exit 1
fi
# Run the specified scraper script with xvfb-run
xvfb-run --server-args="-screen 0 1900x1200x24" python3 "/app/$1"
am i missing something or what??