标签:步骤 file gnu -- add issues ora dpkg tmp
最近在用Docker搭建TensorFlow Serving, 在查阅了官方资料后,发现其文档内有不少冗余的步骤,便一步步排查,终于找到了更简单的Docker镜像构建方法。这里有两种方式:
版本一:
FROM ubuntu:18.04
# Install general packages
RUN apt-get update && apt-get install -y wget && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# New installation of tensorflow-model-server
RUN TEMP_DEB="$(mktemp)" && wget -O "$TEMP_DEB" ‘http://storage.googleapis.com/tensorflow-serving-apt/pool/tensorflow-model-server-1.8.0/t/tensorflow-model-server/tensorflow-model-server_1.8.0_all.deb‘ \
&& dpkg -i "$TEMP_DEB" \
&& rm -f "$TEMP_DEB" \
&& mkdir /tmp/model-export
EXPOSE 9000
# Serve the model when the container starts
ENTRYPOINT ["tensorflow_model_server"]
CMD ["--port=9000", "--model_name=model", "--model_base_path=/tmp/model-export"]
版本二
FROM ubuntu:18.04
# Install general packages
RUN apt-get update && apt-get install -y curl gnupg
# New installation of tensorflow-model-server
RUN echo "deb [arch=amd64] http://storage.googleapis.com/tensorflow-serving-apt stable tensorflow-model-server tensorflow-model-server-universal" | tee /etc/apt/sources.list.d/tensorflow-serving.list \
&& curl https://storage.googleapis.com/tensorflow-serving-apt/tensorflow-serving.release.pub.gpg | apt-key add - \
&& apt-get update && apt-get install tensorflow-model-server \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* && mkdir /tmp/model-export
EXPOSE 9000
# Serve the model when the container starts
ENTRYPOINT ["tensorflow_model_server"]
CMD ["--port=9000", "--model_name=model", "--model_base_path=/tmp/model-export"]
版本一生成的Docker镜像更小些,所以比较推荐第一种方法。至于为何会有第二个版本,因为是从官方的文档上找到的,而第一个来源自别人所提出问题的解答。
将上述代码保存为dockerfile文件,再执行docker build
命令:
docker build -t tensorflow-serving -f dockerfile .
之后,再通过docker run
启动容器即可:
docker run -p 9000:9000 tensorflow-serving
标签:步骤 file gnu -- add issues ora dpkg tmp
原文地址:https://www.cnblogs.com/kenwoo/p/9157704.html