我从工作目录中创建tar存档
tar -chv . --exclude='build/tarball.tar' > build/tarball.tar
,并希望以此创建图像
sudo docker build - < build/tarball.tar
这是我的dockerfile
FROM node:8.11.3-slim
RUN apt-get update && apt-get install -y
ENV GOSU_VERSION 1.10
RUN set -x \
&& dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
&& rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app
# node-user comes from node-docker-image
RUN chown -R node:node /usr/src/app
EXPOSE 8080
ENV NODE_ENV production
CMD ["gosu","node","npm","start"]
但是,由于节点抛出错误,因此启动图像失败:
Error: Cannot find module '..'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
如果我从目录本身创建映像,则该映像可以工作,如果我指向tar存档,为什么它不起作用?
答案 0 :(得分:0)
根据您的docker版本,我认为您可能想使用docker import:
docker import build/tarball.tar mynode:latest