简体   繁体   English

如何从命令创建 dockerfile 和 docker-compose.yml?

[英]How do I create a dockerfile and docker-compose.yml from the commands?

I have a problem.我有个问题。 I have the following commands.我有以下命令。

docker pull tensorflow/serving

docker run -it -v \folder\model:/model-p 8601:8601 --entrypoint /bin/bash tensorflow/serving

tensorflow_model_server --rest_api_port=8601 --model_name=model --model_base_path=/model/

I would like to add these to a dockerfile and to a docker-compose .yml.我想将这些添加到dockerfile和 docker docker-compose .yml。 The problem is that the models are under the following folder structure.问题是models位于以下文件夹结构下。 So I would have to go back one folder and into another.所以我将不得不返回一个文件夹并进入另一个文件夹。 How exactly do I make it all work?我究竟如何使这一切正常工作?

folder structure文件夹结构

folder
├── model # should be copied to \model
│     └── 1
│         └── ...
│     └── 2
│         └── ...
├── server
│     └── Dockerfile
│     └── docker-compose.yml
FROM tensorflow/serving
services:
  tfserving:
    container_name: tfserving
    image: tensorflow/serving
    ports:
      - "8601:8601"
    volumes:
      - \folder\model

Dockerfile (name it with capital D so it's recognized by docker-compose with just . (dot) since it's in the same folder): Dockerfile(用大写的 D 命名它,以便 docker-compose 用 . (点)识别它,因为它在同一个文件夹中):

FROM tensorflow/serving
EXPOSE 8601
RUN tensorflow_model_server --rest_api_port=8601 --model_name=model --model_base_path=/model/

docker-compose.yml:码头工人-compose.yml:

version: '3'

services:
  tfserving:
    container_name: tfserving
    build: .
    ports:
      - "8601:8601"
    volumes:
      - ../model:/models/model
    environment:
      - TENSORFLOW_SERVING_MODEL_NAME=model
    entrypoint: [ "bash", "-c", "tensorflow_model_server --rest_api_port=8601 --model_name=model --model_base_path=/models/model/"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM