|
| 1 | +# Docker with cortex |
| 2 | + |
| 3 | +We offer two methods for deploying the Cortex environment on Docker. |
| 4 | + |
| 5 | +## Method 1: Use the default Dockerfile with Cortex. |
| 6 | + |
| 7 | +To use this method, you need to follow these steps: |
| 8 | +```bash |
| 9 | +git clone https://github.com/janhq/cortex.git |
| 10 | +cd cortex/docker |
| 11 | +docker build -t cortex:latest . |
| 12 | + |
| 13 | +# Run the container with GPU support |
| 14 | +docker run -it --gpus all -d -p 1337:1337 cortex:latest |
| 15 | + |
| 16 | +# Run the container with CPU support |
| 17 | +docker run -it -d -p 1337:1337 cortex:latest |
| 18 | + |
| 19 | +# After starting, you can access Swagger at http://localhost:1337/api and the API server at http://localhost:1337. |
| 20 | +# Additionally, you can exec into the container and use cortex-cli to perform other operations. |
| 21 | +``` |
| 22 | + |
| 23 | +## Method 2: Use Dockerfile.firewall with the feature to block outbound connections by domain and block inbound connections by API path. |
| 24 | + |
| 25 | +The use case for this method is when you want to host the Cortex API 100% offline, preventing access to remote models like the OpenAI API. Alternatively, you might want to block inbound connections by restricting clients from calling the API to load models `/v1/models/start`. |
| 26 | + |
| 27 | +To use this method, you need to follow these steps: |
| 28 | + |
| 29 | +- Step 1: Edit the contents of the [blocked-domains.txt](./docker/common/blocked-domains.txt) file according to your requirements. Refer to the provided examples in the file. The goal is to block outbound connections to the domains you do not want to allow. |
| 30 | +- Step 2: Edit the contents of the [blocked-paths.txt](./docker/common/blocked-paths.txt) file according to your requirements. Refer to the provided examples in the file. The goal is to block inbound connections to the paths you do not want to allow. |
| 31 | +- Step 3: Build the image with Dockerfile.firewall following the instructions below: |
| 32 | + |
| 33 | + ```bash |
| 34 | + git clone https://github.com/janhq/cortex.git |
| 35 | + cd cortex/docker |
| 36 | + docker build -f Dockerfile.firewall -t cortex-with-firewall:latest . |
| 37 | + |
| 38 | + # Run the container with GPU support |
| 39 | + docker run -it --gpus all -d -p 1337:1337 cortex:latest |
| 40 | + |
| 41 | + # Run the container with CPU support |
| 42 | + docker run -it -d -p 1337:1337 cortex:latest |
| 43 | + |
| 44 | + # After starting, you can access Swagger at http://localhost:1337/api and the API server at http://localhost:1337. |
| 45 | + # Additionally, you can exec into the container and use cortex-cli to perform other operations. |
| 46 | + ``` |
0 commit comments