docker build ignore .dockerignore

Demo project:
https://github.com/qinrui777/api-test-demo

please run command to get a jar : ./gradlew -x jar build

  • before (加.dockerignore 之前)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    ➜  api-test-demo git:(master) ✗ docker  build -t api-demo:no-ignore .
    Sending build context to Docker daemon 109.7MB
    Step 1/3 : FROM openjdk:8-jdk-alpine
    ---> 97bc1352afde
    Step 2/3 : ADD build/libs/api-demo-0.0.1-SNAPSHOT.jar /app.jar
    ---> 7f709f7b4381
    Step 3/3 : ENTRYPOINT ["java","-jar","/app.jar"]
    ---> Running in e43285b4802f
    Removing intermediate container e43285b4802f
    ---> 62d9f7b72b38
    Successfully built 62d9f7b72b38
    Successfully tagged api-demo:no-ignore
  • add .dockerignore

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    ➜  api-test-demo git:(master) ✗ cat .dockerignore
    .git
    .DS_Store
    .gitignore
    README.md
    Jenkinsfile
    Dockerfile
    /images/*
    /src/*
    /jenkins/*
  • after (加.dockerignore 之后)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    ➜  api-test-demo git:(master) ✗ docker  build -t api-demo:have-ignore .
    Sending build context to Docker daemon 17.33MB
    Step 1/3 : FROM openjdk:8-jdk-alpine
    ---> 97bc1352afde
    Step 2/3 : ADD build/libs/api-demo-0.0.1-SNAPSHOT.jar /app.jar
    ---> Using cache
    ---> 7f709f7b4381
    Step 3/3 : ENTRYPOINT ["java","-jar","/app.jar"]
    ---> Using cache
    ---> 62d9f7b72b38
    Successfully built 62d9f7b72b38
    Successfully tagged api-demo:have-ignore
Donate
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2019-2024 John Doe
  • Visitors: | Views:

请我喝杯咖啡吧~