我正在关注本教程:https ://docs.docker.com/get-started/02_our_app/
\n当我按照教程中提到的方式更新 app.js 文件(这只是标签更改)然后重新构建并运行我的映像时,Docker 成功运行了该应用程序,但是当我访问 localhost:3000 时,它给了我一个错误。该应用程序以前工作正常,但现在即使我下载示例项目的新副本并加载它并从头开始按照说明进行操作,访问 localhost:3000 也不会向我显示该应用程序。
\n我得到的错误是这样的:
\n\n\n此页面\xe2\x80\x99t 无法工作
\n
\nlocalhost 未\xe2\x80\x99t 发送任何数据。
\nERR_EMPTY_RESPONSE
这里有关于哪里出了问题的提示吗?我该如何解决它?
\n附加信息:
\n我使用的是带有 m1 芯片的 macOS。
\n这是我的 Docker 文件代码:
\n# syntax=docker/dockerfile:1\n FROM node:12-alpine\n RUN apk add --no-cache python g++ make\n WORKDIR /app\n COPY . .\n RUN yarn install --production\n CMD ["node", "src/index.js"]\nRun Code Online (Sandbox Code Playgroud)\n这是我用来构建和运行 Docker 的命令:
\ndocker build -t getting-started .\n\ndocker run -p 3000:3000 getting-started\nRun Code Online (Sandbox Code Playgroud)\n这是当我点击正在运行的容器时 Docker App 的日志:
\n/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration\n\n/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/\n\n/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh\n\n10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf\n\n10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf\n\n/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh\n\n/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh\n\n/docker-entrypoint.sh: Configuration complete; ready for start up\n\n\n2021/08/13 09:26:50 [notice] 1#1: using the "epoll" event method\n\n2021/08/13 09:26:50 [notice] 1#1: nginx/1.21.1\n\n2021/08/13 09:26:50 [notice] 1#1: built by gcc 10.3.1 20210424 (Alpine 10.3.1_git20210424)\n\n2021/08/13 09:26:50 [notice] 1#1: OS: Linux 5.10.25-linuxkit\n\n2021/08/13 09:26:50 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576\n\n2021/08/13 09:26:50 [notice] 1#1: start worker processes\n\n2021/08/13 09:26:50 [notice] 1#1: start worker process 33\n\n2021/08/13 09:26:50 [notice] 1#1: start worker process 34\n\n2021/08/13 09:26:50 [notice] 1#1: start worker process 35\n\n2021/08/13 09:26:50 [notice] 1#1: start worker process 36\nRun Code Online (Sandbox Code Playgroud)\n一切似乎都正常,除了本地主机,它工作正常,直到我修改文本并重建图像并运行它。
\n我还将 dockerfile 放置在正确的位置,并且没有修改任何其他文件。
\n小智 1
您可以检查一些事项以重新开始:
运行命令: docker ps -a 这将为您提供系统上正在运行/停止的所有容器。它还会列出正在使用的端口,确保只有容器在运行状态下使用您映射的端口,否则会出错。
通过命令停止容器: docker stop 当您运行 docker ps -a 时,容器 SHA 值将以十六进制代码显示在第一列中。
检查 docker 文件的位置,因为他们明确要求将该文件放入应用程序文件夹中,并且入门项目文件夹中已经存在另一个 docker 文件,因此请确保您没有覆盖该文件。
我检查并执行了该任务,它对我来说运行得很好。
| 归档时间: |
|
| 查看次数: |
3231 次 |
| 最近记录: |