Skip to content

Run the pesto docker image

If the build succeeds you should be able to see your image with the following command

docker image ls

Success

REPOSITORY                                                  TAG          IMAGE ID       CREATED         SIZE
algo-service                                                1.0.0.dev0   f04d96bb57f4   4 minutes ago   1.16GB

There are different ways to run the docker image of your algorithm created with pesto build.

  • pesto run docker

pesto run docker '{"image":"file:///opt/algo-service/pesto/tests/resources/test_1/input/image.png"}' algo-service:1.0.0.dev0 /tmp/output_pesto.json
  • pesto run local

With this option, you can run the algorithm from a python environment where all dependencies are installed.

Either from your local environment:

pesto run local '{"image":"file:///opt/algo-service/pesto/tests/resources/test_1/input/image.png"}' /tmp/result.txt

Or from inside the container that has been generated:

docker run -it --rm -v /tmp:/tmp algo-service:1.0.0.dev0 bash -c "pesto run local '{\"image\":\"file:///opt/algo-service/pesto/tests/resources/test_1/input/image.png\"}' /tmp/result.txt"```

  • docker run

You can start a container with you packaged algorithm docker image directly with docker command:

docker run --rm -p 4000:8080 algo-service:1.0.0.dev0

This should start the container so that it can be accessed from http://localhost:4000.

  • start service

You can also launch your web service as follows :

$ python {PESTO_PROJECT_ROOT}/algo_service/scripts/start_service.py

The webservice is by default available on the port 8080 (mapped to the port 4000 in the project) and offers the PESTO endpoints.