构建成功后Docker运行失败,出现语法错误

qpgpyjmq  于 2022-11-28  发布在  Docker
关注(0)|答案(1)|浏览(147)

我在Mac系统中本地建立了Docker映像,然后当我试图运行Docker时,得到以下错误。我尝试了以下两种选项。

# Build OPA Service directory, load policies and data, install and run OPA daemon
FROM alpine:latest
RUN apk --no-cache add curl  
ADD $PWD/data /data
VOLUME /data
RUN curl -L -o opa https://openpolicyagent.org/downloads/v0.46.1/opa_darwin_amd64
RUN chmod 755 ./opa 
EXPOSE 8181
CMD ./opa run -s ./data --skip-version-check

Docker构建命令
docker build -t opaservice。Docker运行命令我正在执行docker run opaservice记录了错误消息。/opa:行0:语法错误:未结束的引号字串
尝试从CMD更改为ENTRYPOINT,但没有成功
ENTRYPOINT ["./opa”“运行”“-s”“./data”“--跳过版本检查”]

edqdpe6u

edqdpe6u1#

我试着重新创作,这对我很有效.

root@swarm01:/myworkspace/docker# cat Dockerfile
FROM alpine:latest
RUN apk --no-cache add curl
ADD $PWD/data /data
VOLUME /data
RUN curl -L -o opa https://openpolicyagent.org/downloads/v0.46.1/opa_darwin_amd64
RUN chmod 755 ./opa
EXPOSE 8181
#CMD ./opa run -s ./data --skip-version-check
ENTRYPOINT ["./opa" "run" "-s" "./data" "--skip-version-check"]

我创建了一个空的数据目录。

root@swarm01:/myworkspace/docker# mkdir data
root@swarm01:/myworkspace/docker# docker build -t test .
Sending build context to Docker daemon   2.56kB
Step 1/8 : FROM alpine:latest
 ---> bfe296a52501
Step 2/8 : RUN apk --no-cache add curl
 ---> Using cache
 ---> b535a243661d
Step 3/8 : ADD $PWD/data /data
 ---> 4be29d67af7c
Step 4/8 : VOLUME /data
 ---> Running in 508d5eb2331d
Removing intermediate container 508d5eb2331d
 ---> 3e4399d19162
Step 5/8 : RUN curl -L -o opa https://openpolicyagent.org/downloads/v0.46.1/opa_darwin_amd64
 ---> Running in bb11fb2a5316
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    81  100    81    0     0    414      0 --:--:-- --:--:-- --:--:--   415
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100 57.8M  100 57.8M    0     0  6976k      0  0:00:08  0:00:08 --:--:--  9.9M
Removing intermediate container bb11fb2a5316
 ---> b87791a27ae9
Step 6/8 : RUN chmod 755 ./opa
 ---> Running in f69cfcc4d253
Removing intermediate container f69cfcc4d253
 ---> a6e4cd0e6e34
Step 7/8 : EXPOSE 8181
 ---> Running in e48a8bf4aced
Removing intermediate container e48a8bf4aced
 ---> db4b8ba5fb95
Step 8/8 : ENTRYPOINT ["./opa" "run" "-s" "./data" "--skip-version-check"]
 ---> Running in e6cf0d68f2c8
Removing intermediate container e6cf0d68f2c8
 ---> b0f0ba930f81
Successfully built b0f0ba930f81
Successfully tagged test:latest

相关问题