Closed cyrilfr closed 4 years ago
@cyrilfr Could you print out the exact error output you're seeing on sbt, as well as the output of docker version --format '{{.Server.Version}}'
?
@eed3si9n sure:
$ docker version --format '{{.Server.Version}}'
17.05.0-ce
$ sbt docker:publishLocal
[info] Loading global plugins from /home/cyrilfr/.sbt/0.13/plugins
[info] Loading project definition from /home/cyrilfr/Documents/MyProject/project
[info] Updating {file:/home/cyrilfr/Documents/MyProject/project/}myproject-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to MyProject (in build file:/home/cyrilfr/Documents/MyProject/)
[info] Wrote /home/cyrilfr/Documents/MyProject/target/scala-2.12/myproject_2.12-1.0-SNAPSHOT.pom
[info] Wrote /home/cyrilfr/Documents/MyProject/common/target/scala-2.12/myprojectcommon_2.12-1.0-SNAPSHOT.pom
[info] Wrote /home/cyrilfr/Documents/MyProject/microapps/laundry/target/scala-2.12/myprojecta_2.12-1.0-SNAPSHOT.pom
[info] Wrote /home/cyrilfr/Documents/MyProject/microapps/charger/target/scala-2.12/myprojectb_2.12-1.0-SNAPSHOT.pom
[success] All package validations passed
[info] Sending build context to Docker daemon 77.88MB
[info] Step 1/21 : FROM openjdk:8-jre-alpine as stage0
[info] ---> f7a292bbb70c
[info] Step 2/21 : WORKDIR /opt/docker
[info] ---> Using cache
[info] ---> 42a5d037a11a
[info] Step 3/21 : COPY opt /opt
[info] ---> Using cache
[info] ---> 9d3658d7b891
[info] Step 4/21 : USER root
[info] ---> Using cache
[info] ---> c560e1e6f8b9
[info] Step 5/21 : RUN chmod -R u=rX,g=rX /opt/docker
[info] ---> Using cache
[info] ---> 4d87a892a782
[info] Step 6/21 : RUN chmod u+x,g+x /opt/docker/bin/myproject
[info] ---> Using cache
[info] ---> 9b124a084276
[info] Step 7/21 : FROM openjdk:8-jre-alpine
[info] ---> f7a292bbb70c
[info] Step 8/21 : RUN apk --update add bash
[info] ---> Using cache
[info] ---> 26c81d4fa785
[info] Step 9/21 : USER root
[info] ---> Using cache
[info] ---> f3ecaff29620
[info] Step 10/21 : RUN id -u root 1>/dev/null 2>&1 || (( getent group 0 1>/dev/null 2>&1 || ( type groupadd 1>/dev/null 2>&1 && groupadd -g 0 root || addgroup -g 0 -S root )) && ( type useradd 1>/dev/null 2>&1 && useradd --system --create-home --uid 1001 --gid 0 root || adduser -S -u 1001 -G root root ))
[info] ---> Using cache
[info] ---> 0680b5bfa406
[info] Step 11/21 : WORKDIR /opt/docker
[info] ---> Using cache
[info] ---> d7cac7f9560f
[info] Step 12/21 : COPY --from=stage0 --chown=root:root /opt/docker /opt/docker
[error] Unknown flag: chown
java.lang.RuntimeException: Nonzero exit value: 1
at com.typesafe.sbt.packager.docker.DockerPlugin$.publishLocalDocker(DockerPlugin.scala:507)
at com.typesafe.sbt.packager.docker.DockerPlugin$$anonfun$projectSettings$24.apply(DockerPlugin.scala:193)
at com.typesafe.sbt.packager.docker.DockerPlugin$$anonfun$projectSettings$24.apply(DockerPlugin.scala:191)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[error] (root/docker:publishLocal) Nonzero exit value: 1
[error] Total time: 2 s, completed Aug 27, 2019 3:33:12 PM
I think there's a bug in validation logic. Docker 17.05.0-ce allows multi-stage, but doesn't have --chown
flag used by the multi-stage permission strategy implemented in https://github.com/sbt/sbt-native-packager/pull/1190.
The workaround would be to put:
import com.typesafe.sbt.packager.docker._
ThisBuild / dockerPermissionStrategy := DockerPermissionStrategy.None // or DockerPermissionStrategy.Run
or upgrade to more recent Docker.
I upgraded my Docker version:
$ docker version --format '{{.Server.Version}}'
19.03.1
I then pass the --chown
flag issue but I had another issue:
[info] Sending build context to Docker daemon 78.86MB
[info] Step 1/21 : FROM openjdk:8-jre-alpine as stage0
[info] ---> f7a292bbb70c
[info] Step 2/21 : WORKDIR /opt/docker
[info] ---> Using cache
[info] ---> 3f4e970b7c63
[info] Step 3/21 : COPY opt /opt
[info] ---> 3f81ccd4f62c
[info] Step 4/21 : USER root
[info] ---> Running in 5bbb6f45b09b
[info] Removing intermediate container 5bbb6f45b09b
[info] ---> 167232e06866
[info] Step 5/21 : RUN ["chmod", "-R", "u=rX,g=rX", "/opt/docker"]
[info] ---> Running in 463265344c8f
[info] Removing intermediate container 463265344c8f
[info] ---> 0f32e99a92ab
[info] Step 6/21 : RUN ["chmod", "u+x,g+x", "/opt/docker/bin/myproject"]
[info] ---> Running in e585ca666afd
[info] Removing intermediate container e585ca666afd
[info] ---> 6c7be9fc0ee1
[info] Step 7/21 : FROM openjdk:8-jre-alpine
[info] ---> f7a292bbb70c
[info] Step 8/21 : RUN ["apk", "--update", "add", "bash"]
[info] ---> Using cache
[info] ---> 2a42e20b5bd4
[info] Step 9/21 : USER root
[info] ---> Using cache
[info] ---> 8cc6253ef571
[info] Step 10/21 : RUN id -u root 1>/dev/null 2>&1 || (( getent group 0 1>/dev/null 2>&1 || ( type groupadd 1>/dev/null 2>&1 && groupadd -g 0 root || addgroup -g 0 -S root )) && ( type useradd 1>/dev/null 2>&1 && useradd --system --create-home --uid 1001 --gid 0 root || adduser -S -u 1001 -G root root ))
[info] ---> Using cache
[info] ---> 8e2fca065b67
[info] Step 11/21 : WORKDIR /opt/docker
[info] ---> Using cache
[info] ---> 43dbe0ac5c45
[info] Step 12/21 : COPY --from=stage0 --chown=root:root /opt/docker /opt/docker
[info] ---> 48d1087336a8
[info] Step 13/21 : EXPOSE 80 9000
[info] ---> Running in a50fb8593b91
[info] Removing intermediate container a50fb8593b91
[info] ---> 30f819cef39f
[info] Step 14/21 : RUN ["mkdir", "-p", "/opt/docker/ipk", "/opt/docker/ipkv2", "/opt/docker/images", "/opt/docker/imagesv2", "/opt/docker/ebics", "/opt/docker/machine-manuals"]
[info] ---> Running in c5dbcf928a24
[info] Removing intermediate container c5dbcf928a24
[info] ---> f2e85eceedb9
[info] Step 15/21 : RUN ["chown", "-R", "root:root", "/opt/docker/ipk", "/opt/docker/ipkv2", "/opt/docker/images", "/opt/docker/imagesv2", "/opt/docker/ebics", "/opt/docker/machine-manuals"]
[info] ---> Running in 4988bd4c4f8b
[info] Removing intermediate container 4988bd4c4f8b
[info] ---> 084e3b7da67a
[info] Step 16/21 : VOLUME ["/opt/docker/ipk", "/opt/docker/ipkv2", "/opt/docker/images", "/opt/docker/imagesv2", "/opt/docker/ebics", "/opt/docker/machine-manuals"]
[info] ---> Running in 5599298d4a7e
[info] Removing intermediate container 5599298d4a7e
[info] ---> 183f7ac0c011
[info] Step 17/21 : USER 1001:0
[info] ---> Running in ae3bd2ccf8c8
[info] Removing intermediate container ae3bd2ccf8c8
[info] ---> 2ddee3a0cf7d
[info] Step 18/21 : ENTRYPOINT ["bin/myproject"]
[info] ---> Running in 18aea6dad585
[info] Removing intermediate container 18aea6dad585
[info] ---> 3a1cbca4f404
[info] Step 19/21 : CMD ["-Dpidfile.path=/dev/null", "-J-XX:+UnlockExperimentalVMOptions", "-J-XX:+UseCGroupMemoryLimitForHeap", "-J-XX:MaxRAMFraction=1"]
[info] ---> Running in 7eb504c57119
[info] Removing intermediate container 7eb504c57119
[info] ---> 87947603cf68
[info] Step 20/21 : RUN ["apk", "add", "ca-certificates", "ttf-freefont", "tzdata"]
[info] ---> Running in 8be4fb64316d
[info] ERROR: Unable to lock database: Permission denied
[info] ERROR: Failed to open apk database: Permission denied
[info] Removing intermediate container 8be4fb64316d
[error] The command 'apk add ca-certificates ttf-freefont tzdata' returned a non-zero code: 99
java.lang.RuntimeException: Nonzero exit value: 99
at com.typesafe.sbt.packager.docker.DockerPlugin$.publishLocalDocker(DockerPlugin.scala:507)
at com.typesafe.sbt.packager.docker.DockerPlugin$$anonfun$projectSettings$24.apply(DockerPlugin.scala:193)
at com.typesafe.sbt.packager.docker.DockerPlugin$$anonfun$projectSettings$24.apply(DockerPlugin.scala:191)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[error] (root/docker:publishLocal) Nonzero exit value: 99
[error] Total time: 26 s, completed Aug 29, 2019 11:27:06 AM
I set daemonUser in Docker := "root"
in my build.sbt
file so it should by fine.
I still experience the issue on another PC:
Play 2.7.5
Docker version 19.03.12
sbt-native-packager 1.7.4
Ubuntu 20.04.1 LTS
sbt docker:publish
[info] Loading settings for project jarvis-build from plugins.sbt ...
[info] Loading project definition from /project
[info] Loading settings for project root from build.sbt,ui-build.sbt ...
[info] Loading settings for project charger from build.sbt ...
[info] Loading settings for project laundry from build.sbt ...
[info] Loading settings for project common from build.sbt ...
[info] Set current project to Jarvis
[info] Wrote /target/scala-2.12/jarvis_2.12-2.0-SNAPSHOT.pom
[info] Main Scala API documentation to /target/scala-2.12/api...
[info] running com.iheart.playSwagger.SwaggerSpecRunner /target/swagger/swagger.json routes models com.iheart.playSwagger.ParametricTypeNamesTransformer false 2.0-SNAPSHOT false false none
model contains 15 documentable templates
[info] Main Scala API documentation successful.
[info] Wrote /common/target/scala-2.12/common_2.12-2.0-SNAPSHOT.pom
[info] Main Scala API documentation to /common/target/scala-2.12/api...
model contains 166 documentable templates
[info] Main Scala API documentation successful.
[info] Wrote /microapps/laundry/target/scala-2.12/laundryapp_2.12-2.0-SNAPSHOT.pom
[info] Main Scala API documentation to /microapps/laundry/target/scala-2.12/api...
model contains 117 documentable templates
[info] Main Scala API documentation successful.
[info] Wrote /microapps/charger/target/scala-2.12/chargerapp_2.12-2.0-SNAPSHOT.pom
[info] Main Scala API documentation to /microapps/charger/target/scala-2.12/api...
model contains 67 documentable templates
[info] Main Scala API documentation successful.
[success] All package validations passed
[info] Sending build context to Docker daemon 104.7MB
[info] Step 1/28 : FROM alpine:latest as stage0
[info] ---> a24bb4013296
[info] Step 2/28 : LABEL snp-multi-stage="intermediate"
[info] ---> Running in 8c4f78220acc
[info] Removing intermediate container 8c4f78220acc
[info] ---> a26197158a80
[info] Step 3/28 : LABEL snp-multi-stage-id="e30cdc5e-2c80-4295-8aff-1d6a8a51f223"
[info] ---> Running in 328bc1699817
[info] Removing intermediate container 328bc1699817
[info] ---> e773a953012c
[info] Step 4/28 : WORKDIR /opt/docker
[info] ---> Running in 513b68ea8ae8
[info] Removing intermediate container 513b68ea8ae8
[info] ---> 5d6231e071ba
[info] Step 5/28 : COPY opt /opt
[info] ---> 9786840bacb6
[info] Step 6/28 : COPY 1/opt /1/opt
[info] ---> 51a8c623d7bd
[info] Step 7/28 : COPY 2/opt /2/opt
[info] ---> 1f038dc7478c
[info] Step 8/28 : USER root
[info] ---> Running in 9273e5400358
[info] Removing intermediate container 9273e5400358
[info] ---> 81a816c30173
[info] Step 9/28 : RUN ["chmod", "-R", "u=rX,g=rX", "/opt/docker"]
[info] ---> Running in 8b6b8cedf0b6
[info] Removing intermediate container 8b6b8cedf0b6
[info] ---> 689d0f01764d
[info] Step 10/28 : RUN ["chmod", "-R", "u=rX,g=rX", "/1/opt/docker"]
[info] ---> Running in 2a6b3ab2a170
[info] Removing intermediate container 2a6b3ab2a170
[info] ---> c9741ce8c2d0
[info] Step 11/28 : RUN ["chmod", "-R", "u=rX,g=rX", "/2/opt/docker"]
[info] ---> Running in 7892b3d12324
[info] Removing intermediate container 7892b3d12324
[info] ---> 7700449bb74e
[info] Step 12/28 : RUN ["chmod", "u+x,g+x", "/1/opt/docker/bin/jarvis"]
[info] ---> Running in bf58c6e91e4e
[info] Removing intermediate container bf58c6e91e4e
[info] ---> e3e1245d188b
[info] Step 13/28 : FROM alpine:latest as mainstage
[info] ---> a24bb4013296
[info] Step 14/28 : USER root
[info] ---> Running in 1c403bcd2497
[info] Removing intermediate container 1c403bcd2497
[info] ---> 9e122e315312
[info] Step 15/28 : RUN id -u root 1>/dev/null 2>&1 || (( getent group 0 1>/dev/null 2>&1 || ( type groupadd 1>/dev/null 2>&1 && groupadd -g 0 root || addgroup -g 0 -S root )) && ( type useradd 1>/dev/null 2>&1 && useradd --system --create-home --uid 1001 --gid 0 root || adduser -S -u 1001 -G root root ))
[info] ---> Running in 1ed947e11cbe
[info] Removing intermediate container 1ed947e11cbe
[info] ---> 2b6999336563
[info] Step 16/28 : WORKDIR /opt/docker
[info] ---> Running in 2e0b834332b6
[info] Removing intermediate container 2e0b834332b6
[info] ---> 5916657bfcd5
[info] Step 17/28 : COPY --from=stage0 --chown=root:root /opt/docker /opt/docker
[info] ---> 6029aa8755d7
[info] Step 18/28 : COPY --from=stage0 --chown=root:root /1/opt/docker /opt/docker
[info] ---> 9b6845779238
[info] Step 19/28 : COPY --from=stage0 --chown=root:root /2/opt/docker /opt/docker
[info] ---> f35a0652d864
[info] Step 20/28 : EXPOSE 80
[info] ---> Running in 7c39c012a6c5
[info] Removing intermediate container 7c39c012a6c5
[info] ---> b55434bc80f9
[info] Step 21/28 : RUN ["mkdir", "-p", "/opt/docker/ipk", "/opt/docker/images", "/opt/docker/ebics", "/opt/docker/machine-manuals"]
[info] ---> Running in f13435dc30d1
[info] Removing intermediate container f13435dc30d1
[info] ---> 130ffa1f2d35
[info] Step 22/28 : RUN ["chown", "-R", "root:root", "/opt/docker/ipk", "/opt/docker/images", "/opt/docker/ebics", "/opt/docker/machine-manuals"]
[info] ---> Running in 5f1f281ff3f1
[info] Removing intermediate container 5f1f281ff3f1
[info] ---> a670eb4f653b
[info] Step 23/28 : VOLUME ["/opt/docker/ipk", "/opt/docker/images", "/opt/docker/ebics", "/opt/docker/machine-manuals"]
[info] ---> Running in 3ce1bbd60ee1
[info] Removing intermediate container 3ce1bbd60ee1
[info] ---> 4580e59ba73c
[info] Step 24/28 : USER 1001:0
[info] ---> Running in efd986d0ea9b
[info] Removing intermediate container efd986d0ea9b
[info] ---> e4806475cc65
[info] Step 25/28 : ENTRYPOINT ["bin/jarvis"]
[info] ---> Running in 118edf78ac05
[info] Removing intermediate container 118edf78ac05
[info] ---> 8d7f5cf8a674
[info] Step 26/28 : CMD ["-Dconfig.resource=prod.conf", "-Dpidfile.path=/dev/null"]
[info] ---> Running in a779f044763e
[info] Removing intermediate container a779f044763e
[info] ---> 51e7204510ca
[info] Step 27/28 : RUN ["apk", "add", "openjdk11-jre", "nfs-utils", "ca-certificates", "ttf-freefont", "tzdata"]
[info] ---> Running in 2c4a2174a03b
[info] ERROR: Unable to lock database: Permission denied
[info] ERROR: Failed to open apk database: Permission denied
[info] Removing intermediate container 2c4a2174a03b
[error] The command 'apk add openjdk11-jre nfs-utils ca-certificates ttf-freefont tzdata' returned a non-zero code: 99
[info] Removing intermediate image(s) (labeled "snp-multi-stage-id=e30cdc5e-2c80-4295-8aff-1d6a8a51f223")
[info] Deleted Images:
[info] deleted: sha256:e3e1245d188b49fe7ec4e828b843fd317291399c56496d837e9241f8feac15a9
[info] deleted: sha256:cc79f970bedf44d20615b6aba29e543c589b498fbdc61b3e26c7bb0809bab6e3
[info] deleted: sha256:7700449bb74ea47d01e42ab07af852abc1a5ba8fae35d48ad832c7d2d34521b8
[info] deleted: sha256:b7cb7d0ffbfd1273da4218aa86390ac70f220fafdc8be4ac33a253030d06931e
[info] deleted: sha256:c9741ce8c2d0994ab49f213bee69a626991a1b5c9b063ed7d8331a2275800247
[info] deleted: sha256:938a75a7c71266996cf761d5571a7dd567df0e74e8d9452b2fa09a12e6a50118
[info] deleted: sha256:689d0f01764dee5da2e71b65e3798ed5789d9c6879487e396434f3c00e9d207d
[info] deleted: sha256:3e052728b15b8ad6d268f05cdbd7005655f111f9f3e0562ac41eb935131b3eca
[info] deleted: sha256:81a816c30173800197d83e025825c984868547e72fa6e85da4771bf037bf7367
[info] deleted: sha256:1f038dc7478c4b8c4643ed315c0db99e75ae2a7f0fd3acd61a1487f0481d93fb
[info] deleted: sha256:20850acfbea0949f666e1e49432f06b89d24cb28b6744d32da952986b31eb970
[info] deleted: sha256:51a8c623d7bd65eb8ffb4fe9be2a9a35677e933759c2e26431b82f338ef0a272
[info] deleted: sha256:96efaa965b81edba4c8d57e4d049792a3bde2b65e8d869a6240d41519d66b441
[info] deleted: sha256:9786840bacb67633a10efa18e3a19cf92ae085eb99fa8db523bfddbb4d144e48
[info] deleted: sha256:d8d602125432c89e4476064e1d5c24c6f2185fa834b15be03e047630a68094dc
[info] deleted: sha256:5d6231e071ba680715f3beca41c04460a13cce68fe620daae12bd45c0f4d59c5
[info] deleted: sha256:323cc964c8fb58beb1ab292d317563251cc13715856e64f7ed55cb468e7f1093
[info] deleted: sha256:e773a953012c856b06eb4805bbe33d5a6af06c7e514cca67f2b2a00692ac8e19
[info] deleted: sha256:a26197158a802bbab4f98980f18429ae8bafa8eaf937d6ca49ab41295188dba8
[info] Total reclaimed space: 209MB
[error] java.lang.RuntimeException: Nonzero exit value: 99
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.publishLocalDocker(DockerPlugin.scala:631)
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.$anonfun$projectSettings$49(DockerPlugin.scala:247)
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.$anonfun$projectSettings$49$adapted(DockerPlugin.scala:239)
[error] at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] at sbt.std.Transform$$anon$4.work(Transform.scala:67)
[error] at sbt.Execute.$anonfun$submit$2(Execute.scala:281)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19)
[error] at sbt.Execute.work(Execute.scala:290)
[error] at sbt.Execute.$anonfun$submit$1(Execute.scala:281)
[error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error] at java.base/java.lang.Thread.run(Thread.java:834)
[error] (Docker / publishLocal) Nonzero exit value: 99
[error] Total time: 38 s, completed Aug 17, 2020, 12:05:21 PM
This seems to be a permission error.
[info] ERROR: Unable to lock database: Permission denied
[info] ERROR: Failed to open apk database: Permission denied
....
[error] The command 'apk add openjdk11-jre nfs-utils ca-certificates ttf-freefont tzdata' returned a non-zero code: 99
You try to install something, but you aren't allowed to. I'm not too familiar with docker, but I guess the intermediate image is not executed with the proper user.
In the logs you see that all the installation stuff is done as USER root
. Then you try to install stuff as the actual user the docker image is running and not root
. So you need to move the apk
install stuff into the first phase.
The user is set using daemonUser in Docker := "root"
.
Here is my build.sbt:
lazy val dockerSettings = Seq(
aggregate in Docker := false,
daemonUser in Docker := "root",
dockerBaseImage := "alpine:latest",
dockerRepository := Some("eeproperty"),
dockerExposedPorts := Seq(80),
dockerExposedVolumes := Seq(
"/opt/docker/ipk",
"/opt/docker/images",
"/opt/docker/ebics",
"/opt/docker/machine-manuals"
),
dockerEntrypoint := Seq("bin/%s" format executableScriptName.value),
dockerCmd := Seq(
"-Dconfig.resource=prod.conf",
"-Dpidfile.path=/dev/null"
),
dockerCommands ++= Seq(
ExecCmd("RUN", "apk", "add", "openjdk11-jre", "nfs-utils", "ca-certificates", "ttf-freefont", "tzdata"),
ExecCmd("RUN", "cp", "/usr/share/zoneinfo/Europe/Zurich", "/etc/localtime")
)
)
It used to work perfectly with SBT native packager 1.3.5.
Thanks for the details. The issue is as I described a bit quirky before that you append the additional RUN commands, while you must add them in the first image.
dockerCommands ++= {
val currentDockerCommands = dockerCommands.value
currentDockerCommands.flatMap {
case cmd @ Cmd("FROM", _ , "as", "mainstage") => cmd ++ Seq(
ExecCmd("RUN", "apk", "add", "openjdk11-jre", "nfs-utils", "ca-certificates", "ttf-freefont", "tzdata"),
ExecCmd("RUN", "cp", "/usr/share/zoneinfo/Europe/Zurich", "/etc/localtime")
)
case cmd => List(cmd)
}
}
or something like that. I did not try this out
Thanks for the snippet, I'm not a Scala crack. IntelliJ says on flatMap
: Cannot resolve overloaded method 'flatMap'.
Maybe this annotation in SBT code source has something to do with this?
@scala.annotation.compileTimeOnly("
valuecan only be used within a task or setting macro, such as :=, +=, ++=, Def.task, or Def.setting.")
The compiler says:
error: value ++ is not a member of com.typesafe.sbt.packager.docker.Cmd
case cmd @ Cmd("FROM", _ , "as", "mainstage") => cmd ++ Seq(
^
I've been able to fix this error with:
dockerCommands := dockerCommands.value.flatMap {
case cmd @ Cmd("FROM", _, "as", "mainstage") => List(cmd,
ExecCmd("RUN", "apk", "add", "openjdk11-jre", "nfs-utils", "ca-certificates", "ttf-freefont", "tzdata"),
ExecCmd("RUN", "cp", "/usr/share/zoneinfo/Europe/Zurich", "/etc/localtime")
)
case other => List(other)
}
Thanks a lot!
Ah! Yes, your code looks much better :smile:
I experience the same issue with
Is it still related to the Docker version detection?