dockertensorflowdocker-composedockerfiletensorflow-serving

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. The problem is that the models are under the following folder structure. 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

Solution

  • Dockerfile (name it with capital D so it's recognized by docker-compose with just . (dot) since it's in the same folder):

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

    docker-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/"]