当latest 映像更新时,onbuild 映像似乎没有重建,这导致 docker 拉取了基础映像的过时版本。
您最好忽略onbuild 图像并获取最新的图像。
Here你可以找到详情。
测试最新的图像是否有效。
首先我尝试从镜像中运行一个容器:
$ docker run -d -p 80:80 gatsbyjs/gatsby:latest
这行得通。 Nginx 在这里运行。
$ curl localhost
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
删除容器。
我将全局安装 gatsby
$ npm install --global gatsby-cli
现在我从 here 克隆了一个基本的 gatsbyjs 站点。
$ git clone https://github.com/gatsbyjs/gatsby-starter-hello-world.git
$ cd gatsby-starter-hello-world\
我将建立网站(如您的文档中所述)。
$ npm 安装
$ gatsby 构建
现在我有一个public/ 存储库。这是带有:onbuild 标签的图像所期望的。
LICENSE README.md node_modules/ package-lock.json package.json public/ src/
现在我可以在 git repo 中编写我的 Dockerfile。我将使用最新的标签(不是 onbuild),这意味着我必须编写自己的 COPY 或 ADD 步骤。它包含:
FROM gatsbyjs/gatsby:latest
COPY public/ /pub
我将构建 docker 映像
$ docker build -t my-site .
Sending build context to Docker daemon 2.791MB
Step 1/2 : FROM gatsbyjs/gatsby:latest
---> 21fc487ad83e
Step 2/2 : COPY public/ /pub
---> 87f5ea1018ee
Removing intermediate container fd35cace6ef0
Successfully built 87f5ea1018ee
Successfully tagged my-site:latest
最后我可以从镜像中启动一个 docker 容器。
$ docker run -d -p 80:80 my-site
现在我可以curl我的localhost:80
$ curl localhost
$<!DOCTYPE html><html><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="ie=edge"/><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/><link rel="preload" href="/component---src-pages-index-js-3a9c8c6504e39c44af75.js" as="script"/><link rel="preload" href="/path---index-a0e39f21c11f6a62c5ab.js" as="script"/><link rel="preload" href="/app-fcd7d98e3197e34ce021.js" as="script"/><link rel="preload" href="/commons-eef92a68af65d2662677.js" as="script"/><style id="gatsby-inlined-css"></style></head><body><div id="___gatsby"><div data-reactroot="" data-reactid="1" data-react-checksum="-122217258"><div data-reactid="2">Hello world!</div></div></div><script id="webpack-manifest">/*<![CDATA[*/window.webpackManifest={"231608221292675":"app-fcd7d98e3197e34ce021.js","35783957827783":"component---src-pages-index-js-3a9c8c6504e39c44af75.js","142629428675168":"path---index-a0e39f21c11f6a62c5ab.js"}/*]]>*/</script><script>/*<![CDATA[*/!function(e,t,r){function n(){for(;d[0]&&"loaded"==d[0][f];)c=d.shift(),c[o]=!i.parentNode.insertBefore(c,i)}for(var..