Docker 运行 vue-app 但权限被拒绝

问题描述 投票:0回答:1

我尝试 docker 构建我的 vue 应用程序并且它通过了,但是当我尝试 docker run 时出现了问题。

我的 Dockerfile 如下:

FROM node:latest AS build

RUN mkdir /app
WORKDIR /app

COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
RUN npm install

COPY . .

USER node

EXPOSE 8686

CMD ["npm", "run", "serve"]

在我使用command通过docker构建后运行我的项目之后

sudo docker run -p 8888:8686 my-vue-app

我得到了:

[sudo] password for user: 

> [email protected] serve
> vue-cli-service serve --port 8686

sh: 1: vue-cli-service: Permission denied

如何成功 docker 运行我的项目

这是docker构建我的项目时的信息:

我使用推荐:

sudo docker build -t my-vue-app .

我得到了:

[+] Building 34.1s (11/11) FINISHED                                                                                                        
 => [internal] load build definition from Dockerfile                                                                                  0.0s
 => => transferring dockerfile: 410B                                                                                                  0.0s
 => [internal] load metadata for docker.io/library/node:latest                                                                        2.5s
 => [internal] load .dockerignore                                                                                                     0.0s
 => => transferring context: 2B                                                                                                       0.0s
 => [1/6] FROM docker.io/library/node:latest@sha256:64c46a664eccedec63941dab4027c178a36debe08a232d4f9d7da5aca91cff3d                 13.6s
 => => resolve docker.io/library/node:latest@sha256:64c46a664eccedec63941dab4027c178a36debe08a232d4f9d7da5aca91cff3d                  0.0s
 => => sha256:64c46a664eccedec63941dab4027c178a36debe08a232d4f9d7da5aca91cff3d 1.21kB / 1.21kB                                        0.0s
 => => sha256:aa70582e85cf5d05c7505bed0cfbf6846e369253f88f8eeeb0f9f57d86a40274 2.00kB / 2.00kB                                        0.0s
 => => sha256:5199d6829c9501975002f30375c1b1ff47c5a71b8bfa07d9696c33fa6fb42c7b 7.41kB / 7.41kB                                        0.0s
 => => sha256:1468e7ff95fcb865fbc4dee7094f8b99c4dcddd6eb2180cf044c7396baf6fc2f 49.58MB / 49.58MB                                      1.4s
 => => sha256:2cf9c2b42f41b1845f3e4421b723d56146db82939dc884555e077768e18132f4 24.05MB / 24.05MB                                      1.3s
 => => sha256:c4c40c3e3cdf945721f480e1d939aac857876fdb5c33b8fbfcf655c63b0b9428 64.14MB / 64.14MB                                      2.3s
 => => extracting sha256:1468e7ff95fcb865fbc4dee7094f8b99c4dcddd6eb2180cf044c7396baf6fc2f                                             1.6s
 => => sha256:c05cc1123d7e335d59b0f465c23b7ad2ad27f4875b6c3eab41c65a9b50efa382 211.18MB / 211.18MB                                    5.6s
 => => sha256:04f2356c02d21ef160986f7994210be28dab889b9ba0724e126bd2ee4ed21cd6 3.37kB / 3.37kB                                        1.7s
 => => sha256:6ddb20e283af7117b546019c38904abe23562b4c509835e197e90ece86329c8f 52.03MB / 52.03MB                                      3.6s
 => => sha256:1e529f01353c8cc4b282dcf88ea4afda96f67b51b4d50e1d66334db747e4dacb 1.25MB / 1.25MB                                        2.6s
 => => sha256:76462c7b107c254da6e449995ef8040b3445701fc0cbad6d027bb2324b2898fc 451B / 451B                                            2.9s
 => => extracting sha256:2cf9c2b42f41b1845f3e4421b723d56146db82939dc884555e077768e18132f4                                             0.5s
 => => extracting sha256:c4c40c3e3cdf945721f480e1d939aac857876fdb5c33b8fbfcf655c63b0b9428                                             2.0s
 => => extracting sha256:c05cc1123d7e335d59b0f465c23b7ad2ad27f4875b6c3eab41c65a9b50efa382                                             5.6s
 => => extracting sha256:04f2356c02d21ef160986f7994210be28dab889b9ba0724e126bd2ee4ed21cd6                                             0.0s
 => => extracting sha256:6ddb20e283af7117b546019c38904abe23562b4c509835e197e90ece86329c8f                                             1.7s
 => => extracting sha256:1e529f01353c8cc4b282dcf88ea4afda96f67b51b4d50e1d66334db747e4dacb                                             0.0s
 => => extracting sha256:76462c7b107c254da6e449995ef8040b3445701fc0cbad6d027bb2324b2898fc                                             0.0s
 => [internal] load build context                                                                                                     2.2s
 => => transferring context: 203.10MB                                                                                                 2.1s
 => [2/6] RUN mkdir /app                                                                                                              1.7s
 => [3/6] WORKDIR /app                                                                                                                0.0s
 => [4/6] COPY [package.json, package-lock.json*, npm-shrinkwrap.json*, ./]                                                           0.3s
 => [5/6] RUN npm install                                                                                                             9.6s
 => [6/6] COPY . .                                                                                                                    3.7s
 => exporting to image                                                                                                                2.4s
 => => exporting layers                                                                                                               2.4s
 => => writing image sha256:330b1738c423c9e9d53c7465e4ad4b2c581f8682f32e29fd9ef7369745254d4d                                          0.0s
 => => naming to docker.io/library/my-vue-app:latest         
docker vue.js dockerfile
1个回答
0
投票

我听不懂你说的话。

© www.soinside.com 2019 - 2024. All rights reserved.