I created a custom image with the following Dockerfile:
FROM apache/airflow:2.1.1-python3.8
USER root
RUN apt-get update
&& apt-get -y install gcc gnupg2
&& curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
&& curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
&& ACCEPT_EULA=Y apt-get -y install msodbcsql17
&& ACCEPT_EULA=Y apt-get -y install mssql-tools
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
&& echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
&& source ~/.bashrc
RUN apt-get -y install unixodbc-dev
&& apt-get -y install python-pip
&& pip install pyodbc
RUN echo -e “AIRFLOW_UID=$(id -u) nAIRFLOW_GID=0” > .env
USER airflow
The image creates successfully, but when I try to run it, I get this error:
"airflow command error: the following arguments are required: GROUP_OR_COMMAND, see help above."
I have tried supplying a group ID with the –user, but I can’t figure it out.
How can I start this custom Airflow Docker image?
Thanks!
2
Answers
First of all this line is wrong:
RUN echo -e “AIRFLOW_UID=$(id -u) nAIRFLOW_GID=0” > .env
If you are running it with Docker Compose (I presume you took it from https://airflow.apache.org/docs/apache-airflow/stable/start/docker.html), this is something you should run on "Host" machine, not in the image. Remove that line, it has no effect.
Secondly – it really depends what "command" you run. The "GROUP_OR_COMMAND" message you got is the output of "airflow" command. You have not copied the whole output of your command but this is a message you get when you try to run airflow without telling it what to do. When you run the image you will run by default the
airflow
command which has a number of subcommands that can be executed. So the "see help above" message tells you the very thing you should do – look at the help and see what subcommand you wanted to run (and possibly run it).when you extend the official image, it will pass the parametor to "airflow" command which causing this problem. Check this out: https://airflow.apache.org/docs/docker-stack/entrypoint.html#entrypoint-commands