# When I run ray.remote with image\_uri as the parameter, it is successful, but when I change it to ray\_derve, it cannot run successfully

**URL:** <https://discuss.ray.io/t/when-i-run-ray-remote-with-image-uri-as-the-parameter-it-is-successful-but-when-i-change-it-to-ray-derve-it-cannot-run-successfully/21887>\
**Category:** Uncategorized\
**Created:** [February 23, 2025, 6:27am UTC](https://discuss.ray.io/t/when-i-run-ray-remote-with-image-uri-as-the-parameter-it-is-successful-but-when-i-change-it-to-ray-derve-it-cannot-run-successfully/21887 "2025-02-23T06:27:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hang\_zhou](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/hang_zhou/32/7671_2.png) [@hang\_zhou](https://discuss.ray.io/u/hang_zhou)\
**Post date:** [February 23, 2025, 6:27am UTC](https://discuss.ray.io/t/when-i-run-ray-remote-with-image-uri-as-the-parameter-it-is-successful-but-when-i-change-it-to-ray-derve-it-cannot-run-successfully/21887/1 "2025-02-23T06:27:37Z")

</div>

ray Version: 2.42.1  
python = 3.10.12,

I have multiple deployments, but their environments need to be isolated. However, I don’t want to install them at runtime through pip because it’s too time-consuming and unstable. So I installed the environment on Docker Image, but I can’t run it perfectly on Ray Server

**this is Dockerfile**

```auto
# 使用 Miniconda 作为基础镜像

FROM continuumio/miniconda3

# 设置工作目录

WORKDIR /app

# 创建 Conda 环境

RUN conda create --name kolors python=3.10.12

RUN echo "conda activate kolors" >> ~/.bashrc

ENV PATH /opt/conda/envs/kolors/bin:$PATH

# 设置 pip 镜像源为国内源（比如阿里云镜像）

RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

# 安装 Ray 和其他依赖

RUN pip install --upgrade pip

# 将本地的 requirements.txt 复制到容器中的 /app 目录

COPY requirements.txt /app/requirements.txt

# 安装项目的 Python 依赖

RUN pip install -r /app/requirements.txt

# 只需保持环境配置，不需要启动 app.py

# 最终，容器本身不启动任何程序，只需提供环境

CMD ["/bin/bash"]

```

**this is requirements.txt**

emoji

**### this is ray.remoto**

```auto
import ray

runtime_env = {"image_uri": "localhost/kolor_podman_ray"}

ray.init(runtime_env=runtime_env)

@ray.remote
def f():
  import emoji
  return emoji.emojize('Python is :thumbs_up:')

print(ray.get(f.remote()))

```

**this is successful**

 ![截屏2025-02-23 11.24.51](https://us1.discourse-cdn.com/flex020/uploads/ray/original/2X/2/24c54b2e8056590f0c3441f6cb02af4d19610de0.png)

### **this is ray serve**

```auto
import ray
from ray import serve
from fastapi import FastAPI
import ray

# 创建 FastAPI 应用
app = FastAPI()

# 定义 Ray Serve 部署类
@serve.deployment(num_replicas=2)
@serve.ingress(app)
class EmojiService:

    
    def __init__ (self):
        pass

    @app.get("/emoji")
    def get_emoji(self):
        import emoji
        # 处理请求，返回表情字符串
        return emoji.emojize('Python is :thumbs_up:')

# 绑定服务
app= EmojiService.options(ray_actor_options={"runtime_env": {"image_uri": "localhost/kolor_podman_ray"}}).bind()

```

this is fail:

 ![截屏2025-02-23 11.30.04](https://us1.discourse-cdn.com/flex020/uploads/ray/original/2X/6/6015f0ab3e8549174dd038005865ae16c91f7014.jpeg)
