我有在minikube中构建docker映像的脚本。
#set -x
ASSEMBLY_NAME=$(basename ${1})
eval $(minikube docker-env)
echo "Current user is "$USER
echo "Current user groups "$(id -Gn)
ls -la /home/user1/.minikube/certs/ca.pem
cp ${1} jdbc-puller/build/
docker build --build-arg ASSEMBLY_PATH=${ASSEMBLY_NAME} -t ${2} jdbc-puller/build
此脚本从sbt sbt dockerBuild
执行。
这是自定义命令:
dockerBuild := {
s"""./jdbc-puller/build/linux_build.sh ${assembly.value.getAbsolutePath}
|organisation1/jdbc-puller:${gitCurrentBranch.value}_sha${gitHeadCommit.value
.getOrElse("No_Head_Commit")}""".stripLineEnd.stripMargin !
},
但是我不认为这是sbt的问题。 因为脚本输出显示正确的用户和组:
Current user is user1
Current user groups user1 adm cdrom sudo dip plugdev lpadmin sambashare docker
-rw-r--r-- 1 user1 user1 1025 мар 23 18:35 /home/user1/.minikube/certs/ca.pem
could not read CA certificate "/home/user1/.minikube/certs/ca.pem": open /home/user1/.minikube/certs/ca.pem: permission denied
但是如果我直接在shell中运行相同的命令:
docker build --build-arg ASSEMBLY_PATH=navision-jdbc-puller-0.1.user1.prepare-to-development-028aaddff43890720432a2f27ad193a266ecf0ad.jar -t navision/jdbc-puller:prepare-to-development_sha028aaddff43890720432a2f27ad193a266ecf0ad navision-jdbc-puller/build
结果是:
Sending build context to Docker daemon 75.71MB
Step 1/7 : FROM azul/zulu-openjdk-alpine:11.0.2
---> e711110a0ad5
Step 2/7 : ARG ASSEMBLY_PATH=target/scala-2.11/sbt-1.0/assembly.jar
---> Using cache
---> 831efe890156
Step 3/7 : WORKDIR /opt/jdbc-puller
---> Using cache
---> cf252dc46acd
Step 4/7 : RUN ["chown", "-R", "daemon:daemon", "."]
---> Using cache
---> 843a834736ca
Step 5/7 : USER daemon
---> Using cache
---> ea3b9894ceb5
Step 6/7 : COPY $ASSEMBLY_PATH /opt/jdbc-puller/assmebly.jar
---> Using cache
---> 413ba469b2ef
Step 7/7 : ENTRYPOINT ["java -jar /opt/jdbc-puller/assmebly.jar"]
---> Using cache
---> 41c384cbcef6
Successfully built 41c384cbcef6
Successfully tagged navision/jdbc-puller:prepare-to-development_sha028aaddff43890720432a2f27ad193a266ecf0ad
工作。 附加信息
getfacl: Removing leading '/' from absolute path names
# file: home/user1/.minikube/certs/ca.pem
# owner: user1
# group: user1
user::rw-
group::r--
other::r--
请说明我在哪里错了,或者至少我可以检查什么。
答案 0 :(得分:1)
好的,我发现了问题。 有两个错误。
一个是我的,
我不在终端eval $(minikube docker-env)
中运行。
如果从快照安装了minikube或dcoker,则在ubuntu的minikube中第二个。 这里是问题http://computerbryan.com/minikube-on-ubuntu.html的答案。