Build a docker image using python docker sdk

608 views Asked by At

I have the following structure

- Dockerfile
|
_ apps
    |
    -myapi
      |
      - api-1.0.8.json

In the Dockerfile, I have this

FROM mybase

# Simply need to update config file
ARG asset_api=myapi
ARG asset_api_version=1.0.8
COPY $PWD/apps/${asset_api}/api-${asset_api_version}.json /api.json

This works fine when running CLI docker build command

Using the docker sdk for python, I created my api.py file like this

client.images.build(path="./", tag = 'myimage:tag', buildargs={'asset_api': 'myapi', 'asset_api_version': '1.0.8'}, use_config_proxy=True)

I keep getting this error

docker.errors.BuildError: COPY failed: stat /var/lib/docker/tmp/docker-builder289614590/apps/myapi/api-1.0.8.json: no such file or directory

How do I make sure the the file is copied to the build context?

0

There are 0 answers