Lucas
Lucas

Reputation: 589

How to specify absolute path to Dockerfile on docker build

How can I specify -t and -f parameters on docker cloud build job.


- name: 'gcr.io/cloud-builders/docker'
  entrypoint: 'bash'
  args:
  - '-c'
  - |-
          docker build --network=cloudbuild -f pipeline/components/testdocker/Dockerfile  -t europe-west1-docker.pkg.dev/xxx/test .

  dir: 'mc2-AIBooster_POC/'

I get the following error: "docker build" requires exactly 1 argument"

Upvotes: 5

Views: 5920

Answers (2)

Lucas
Lucas

Reputation: 589

By using -f first and then -t .

Make sure to add a dot at the end of your command

docker build --network=cloudbuild -f pipeline/components/testdocker/Dockerfile -t europe-west1-docker.pkg.dev/vf-grp-aib-dev-buildnl/docker-repository/$_PROJECT_ID/$_USER/$_BRANCH/test .

Upvotes: 4

mdobrucki
mdobrucki

Reputation: 522

You forgot to add a dot at the end of you docker build command, the order of flags shouldn't matter:

docker build --network=cloudbuild -t europe-west1-docker.pkg.dev/vf-grp-aib-dev-buildnl/docker-repository/$_PROJECT_ID/$_USER/$_BRANCH/test -f pipeline/components/testdocker/Dockerfile .

More about using docker build here.

Upvotes: 5

Related Questions