Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Add example on exposing docker ports (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
aguschin authored Feb 21, 2023
1 parent 119e876 commit ba40de1
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions content/docs/user-guide/deploying/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,37 @@ CONTAINER ID IMAGE COMMAND CREATED

A lot of parameters can be configured, the full list of which can be accessed
using `mlem deploy run docker_container -h`.

## Example: running REST API service from CLI

```cli
$ mlem deploy run docker_container app.mlem \
--model model \
--server fastapi \
--ports.0 8080:8080
```

You can specify other [servers](/doc/user-guide/serving/) to use. Note that
`--ports.0` exposes port 8080 outside of the container. Each server typically
exposes some specific port. You can check the default port by running
`mlem serve $SERVER --help`.

For some server implementations (like FastAPI) you can also set change the
default listening port. The below command shows how to modify the listening port
to `5000` and than map it on the host network directly on the same port:

```cli
$ mlem deploy run docker_container app.mlem \
--model model \
--server fastapi \
--ports.0 5000:5000 \
--server.port 5000
```

Please note that when running in a docker container, you usually shouldn't care
about the server internal listening port and can use `--ports` to expose the
server to any port to the host network, e.g. `--ports.0 8080:5000`.

Also, keep in mind that the param name in `--server.$PARAM` that controls the
port can be different for different server implementations. Use
`mlem serve $SERVER --help` to find out the right one.

0 comments on commit ba40de1

Please sign in to comment.