---
# System prepended metadata

title: 簡單開啟docker版本
tags: [Omniverse]

---

# 簡單開啟docker版本
2026-01-07


因為我已經寫好 `docker-compose.yaml`
```yaml
services:
  # --- Isaac Sim 5.1.0 ---
  # 必須以 Root 執行，否則無法讀取驅動與內部設定
  isaac-sim:
    image: nvcr.io/nvidia/isaac-sim:5.1.0
    container_name: isaac-sim
    entrypoint: bash
    stdin_open: true
    tty: true
    network_mode: host
    privileged: true
    restart: always
    
    # ✅ [關鍵] Isaac Sim 內部必須是 root
    user: root
    
    environment:
      - ACCEPT_EULA=Y
      - PRIVACY_CONSENT=Y
      - DISPLAY=${DISPLAY}
      - FASTRTPS_DEFAULT_PROFILES_FILE=/tmp/fastdds.xml
      - ROS_DOMAIN_ID=30
      # ✅ 確保指向 root 家目錄
      - HOME=/root
    
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
    
    volumes:
      - /tmp/.X11-unix:/tmp/.X11-unix
      - ${HOME}/.Xauthority:/root/.Xauthority
      
      # --- Cache 掛載 (解決重複下載問題) ---
      - ~/docker/isaac-sim/cache/kit:/isaac-sim/kit/cache:rw
      - ~/docker/isaac-sim/cache/ov:/root/.cache/ov:rw
      - ~/docker/isaac-sim/cache/pip:/root/.cache/pip:rw
      - ~/docker/isaac-sim/cache/glcache:/root/.cache/nvidia/GLCache:rw
      - ~/docker/isaac-sim/cache/computecache:/root/.nv/ComputeCache:rw
      - ~/docker/isaac-sim/cache/warp:/root/.cache/warp:rw
      - ~/docker/isaac-sim/logs:/root/.nvidia-omniverse/logs:rw
      
      - ~/docker/isaac-sim/data:/root/.local/share/ov/data:rw
      - ~/docker/isaac-sim/documents:/root/Documents:rw
      
      # --- 專案存檔區 ---
      - ~/MyRobotProject:/root/MyRobotProject:rw
      - ~/IsaacSim-ros_workspaces/jazzy_ws/fastdds.xml:/tmp/fastdds.xml

      # ✅ [修復貼圖遺失] 關鍵修正
      # 原理：把你的 "MyRobotProject/textures" 掛載到 "錯誤訊息抱怨找不到的路徑"
      # 左邊：你電腦實際存放貼圖的位置
      # 右邊：Log 裡報錯說找不到的位置 (/home/dodo/Downloads/textures)
      - ~/MyRobotProject/textures:/home/dodo/Downloads/textures:rw

  # --- ROS 2 Jazzy 開發環境 ---
  ros2_jazzy:
    image: my_isaac_ros
    container_name: ros_ws_docker
    network_mode: host
    ipc: host
    pid: host
    
    # ✅ 使用你的 UID，解決開發時的權限問題
    user: "${UID}:${GID}"
    
    stdin_open: true
    tty: true
    working_dir: /jazzy_ws
    environment:
      - DISPLAY=${DISPLAY}
      - ROS_DOMAIN_ID=30
      - FASTRTPS_DEFAULT_PROFILES_FILE=/jazzy_ws/fastdds.xml
      - BASH_ENV=/etc/bash.bashrc
      - HOME=/tmp
    volumes:
      - /tmp/.X11-unix:/tmp/.X11-unix
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
      - ~/IsaacSim-ros_workspaces/jazzy_ws:/jazzy_ws
    command: >
      bash -c "source /opt/ros/jazzy/setup.bash && 
               source /jazzy_ws/install/local_setup.bash && 
               bash"

  # --- 自動導航機器人 ---
  navigator:
    image: my_ackermann_bot
    container_name: ackermann_nav
    network_mode: host
    ipc: host
    pid: host
    
    # ✅ [關鍵修正] 強制使用 root 身分，這樣才能讀寫 /root 資料夾
    user: root
    
    stdin_open: true
    tty: true
    privileged: true
    environment:
      - DISPLAY=${DISPLAY}
      - ROS_DOMAIN_ID=30
      - NVIDIA_VISIBLE_DEVICES=all
      - NVIDIA_DRIVER_CAPABILITIES=all
    volumes:
      - /tmp/.X11-unix:/tmp/.X11-unix
      - ~/IsaacSim-ros_workspaces/jazzy_ws:/jazzy_ws
    command: >
      bash -c "chmod -R +x /root/ros2_ws/install &&
               source /opt/ros/jazzy/setup.bash &&
               source /root/ros2_ws/install/setup.bash &&
               ros2 run isaac_ackermann_nav navigator"
```

所以以後打開可以用 `docker-compose` 指令簡化
> **重要**
> 先打
> ```bash
> docker compose up -d
> ```
> 確認他有抓到 docker-compose.yaml 要的容器

### 以後第一步驟：開啟權限
```bash
xhost +local:
```
![Screenshot from 2026-01-07 17-42-37](https://hackmd.io/_uploads/H1Ki5ijVbg.png)

### 第二步：啟動 Isaac Sim
#### 我們進入已經在背景跑的容器，把 GUI 叫出來
```bash
docker exec -it isaac-sim ./runapp.sh
```
![Screenshot from 2026-01-07 17-44-18](https://hackmd.io/_uploads/S11zisiVZg.png)

### 第三步：啟動控制環境（開新分頁）
#### 進入 ROS 開發容器
```bash
docker exec -it ros_ws_docker bash
```
#### ⚠️ 進去後必須先 source (解決 command not found 問題)：
```bash
source /opt/ros/jazzy/setup.bash
source install/setup.bash
```
![Screenshot from 2026-01-07 17-45-34](https://hackmd.io/_uploads/Bkw_isiNWg.png)

#### 然後再跑 launch：
```bash
ros2 launch cmdvel_to_ackermann cmdvel_to_ackermann.launch.py
```
### 第四步：啟動鍵盤控制（再開新分頁）
#### 再次進入 ROS 開發容器
```bash
docker exec -it ros_ws_docker bash
```
#### 載入環境
```bash
source /opt/ros/jazzy/setup.bash
```
#### 執行鍵盤控制
```bash
ros2 run teleop_twist_keyboard teleop_twist_keyboard
```
![Screenshot from 2026-01-07 17-46-02](https://hackmd.io/_uploads/r1WYsiiEZl.png)

### 結束工作
```bash
docker compose down
```



### 昨天做了導航點對點的ros
#### 啟動並直接操作
```bash
docker compose run --rm navigator
```
![Screenshot from 2026-01-07 17-48-11](https://hackmd.io/_uploads/H10JhsiVWe.png)
