Invalid value 'build-arg' when running lima nerdctl compose up
This bug occurs when trying to run nerdctl compose up on a Dockerfile that has been built using a private python library.
A github token is set as a build argument, and that token is then used in the git config of the container in order to clone private GitHub Python libraries, and is also then used in the application run time.
Since switching to nerdctl with lima, I've not been able to get containers running using my container image.
Some more information - running docker compose build also fails with this image.
When using docker desktop, docker compose build worked, or alternatively, running docker compose up worked if I had previously ran docker build .
Reproduce
Put Dockerfile
FROM python:3.9
# Set environment
ENV PYTHONPATH=/data
ENV AWS_DEFAULT_REGION=eu-west-1
ENV FLASK_APP=github_insights.app:create_app
ENV FLASK_RUN_HOST=0.0.0.0
ENV FLASK_ENV=production
ARG GITHUB_TOKEN
WORKDIR /data
RUN git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/<organization>".insteadOf "https://github.com/<organization>"
Run
$ lima nerdctl compose up
WARN[0000] Ignoring: network web_nw: [Driver]
WARN[0000] Ignoring: volume: Bind: [CreateHostPath]
WARN[0000] Ignoring: volume: Bind: [CreateHostPath]
WARN[0000] Ignoring: volume: Bind: [CreateHostPath]
WARN[0000] Ignoring: volume: Bind: [CreateHostPath]
INFO[0000] Ensuring image postgres:11.12
INFO[0000] Building image gip-flask-app_github-insights
error: invalid opt: invalid value build-arg:GITHUB_TOKEN
FATA[0000] unrecognized image format
FATA[0000] error while building image gip-flask-app_github-insights: exit status 1
Expected
$ docker compose up
[+] Running 3/3
⠿ Network gip-flask-app_web_nw Created
⠿ Container postgres-gi Created
⠿ Container gi Created
Attaching to gi, postgres-gi
Versions
$ system_profiler SPSoftwareDataType
Software:
System Software Overview:
System Version: macOS 10.15.7 (19H1615)
Kernel Version: Darwin 19.6.0
Boot Volume: Macintosh HD
Boot Mode: Normal
Computer Name:
User Name:
Secure Virtual Memory: Enabled
System Integrity Protection: Enabled
Time since boot: 6:48
$ lima uname -a
Linux lima-default 5.13.0-27-generic #29-Ubuntu SMP Wed Jan 12 17:36:47 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
$ lima --version
limactl version 0.8.1
$ lima nerdctl --version
nerdctl version 0.16.0
hello,
using limactl version 0.8.1 and nerdctl version 0.16.0 I did not face any issue when building your Dockerfile with :
-
lima nerdctl build -t limaimage --build-arg GITHUB_TOKEN=toto examples/
=> => transferring context: 2B 0.1s
=> [internal] load metadata for docker.io/library/python:3.9 1.6s
=> [1/3] FROM docker.io/library/python:3.9@sha256:bf6f8b201ffac79a1b9fded783e7f0547ad2c2e3e48e96a7a23855c3de14df4b 0.1s
=> => resolve docker.io/library/python:3.9@sha256:bf6f8b201ffac79a1b9fded783e7f0547ad2c2e3e48e96a7a23855c3de14df4b 0.0s
=> CACHED [2/3] WORKDIR /data 0.0s
=> [3/3] RUN git config --global url."https://x-access-token:[email protected]/<organization>".insteadOf "https://github.com/<organization>" 1.4s
=> exporting to oci image format 62.0s
=> => exporting layers
-
lima nerdctl compose -f examples/compose-wordpress/docker-compose.yaml up
=> => extracting sha256:6494e4811622b31c027ccac322ca463937fd805f569a93e6f15c01aade718793 14.1s
=> => extracting sha256:6f9f74896dfa93fe0172f594faba85e0b4e8a0481a0fefd9112efc7e4d3c78f7 55.3s
=> => extracting sha256:fcb6d5f7c98604476fda91fe5f61be5b56fdc398814fb15f7ea998f53023e774 2.6s
=> => extracting sha256:113344dee6600d7c519481610dc55f82d60cc79671b1abc923af25ee94540f60 5.1s
=> => extracting sha256:0cec34188c5a002b80dad4a0101dbbdcaaf7f3f1840a3d2096e14ed2d5a50a61 0.1s
=> => extracting sha256:38d2af50606a944d5e31767582acee00b9579ad2f5216445d1325c29162c77e1 1.7s
=> [2/3] WORKDIR /data 0.1s
=> [3/3] RUN git config --global url."https://x-access-token:[email protected]/<organization>".insteadOf "https://github.com/<organization>" 1.6s
=> exporting to oci image format 41.3s
=> => exporting layers
version: '3.1'
services:
wordpress:
build:
context: /Users/faheddorgaa/go/src/github.com/nerdctl/examples
args:
GITHUB_TOKEN: toto
restart: always
ports:
- 8080:80
Can you share you docker-compose plz!
Thanks for the reply @fahedouch!
Here's the full set up...
docker-compose.yml:
version: '3'
services:
postgres_gi:
container_name: postgres-gi
image: postgres:11.12
environment:
- POSTGRES_USER=postgres
- POSTGRES_DB=github_insights
- POSTGRES_PASSWORD=postgres
ports:
- "5432:5432"
networks:
- web_nw
github-insights:
container_name: gi
build:
context: .
args:
GITHUB_TOKEN:
environment:
- FLASK_APP=github_insights.app:create_app
- FLASK_ENV=development
- GITHUB_ACCESS_TOKEN=<your-token-here>
- PG_HOST=postgres_gi
- PG_USER=postgres
- PG_DATABASE=github_insights
- POSTGRES_PASSWORD=postgres
- DEBUGGER=True
volumes:
- ./demo_data:/data/demo_data
- ./github_insights:/data/github_insights
- ./utils:/data/utils
- ./migrations:/data/migrations
ports:
- "5000:5000"
- "10001:10001"
depends_on:
- "postgres_gi"
networks:
- web_nw
command: sh -c "flask db upgrade && flask database seed & gunicorn --log-config logging.conf --workers 1 --threads 6 --timeout 500 --bind 0.0.0.0:5000 \"github_insights.app:create_app('development')\""
networks:
web_nw:
driver: bridge
Dockerfile:
FROM python:3.9
# Set environment
ENV PYTHONPATH=/data
ENV AWS_DEFAULT_REGION=eu-west-1
ENV FLASK_APP=github_insights.app:create_app
ENV FLASK_RUN_HOST=0.0.0.0
ENV FLASK_ENV=production
ARG GITHUB_TOKEN
WORKDIR /data
RUN git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/<organization>".insteadOf "https://github.com/<organization>"
COPY requirements.txt ./
# Install application dependencies
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
COPY github_insights ./github_insights
COPY demo_data ./demo_data
COPY logging.conf ./logging.conf
COPY migrations ./migrations
COPY utils ./utils
EXPOSE 5000
CMD gunicorn \
--log-config logging.conf \
--bind 0.0.0.0:5000 "github_insights.app:create_app('${FLASK_ENV}')" \
--workers 2 \
--threads 2
I'm afraid the application itself is proprietary, but in a nutshell, for local dev work we spin up a local copy of the app, and a postgres db/virtual network, seeding the db with some dummy data.
hello,
using
limactl version 0.8.1andnerdctl version 0.16.0I did not face any issue when building your Dockerfile with :
lima nerdctl build -t limaimage --build-arg GITHUB_TOKEN=toto examples/
@fahedouch have you tried to do nerdctl compose build --build-arg that seemed to error as if it wasn't passing the build-arg but if I do nerdctl build --build-arg it does seem to work. My compose has 2 dockerfiles to be built with the same build-arg.