File size: 9,909 Bytes
3044426
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# Copyright (c) 2022-2025, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause

# Isaac Sim base container: https://catalog.ngc.nvidia.com/orgs/nvidia/containers/isaac-sim
# Please check the NGC container page for license information.

# Base image
ARG ISAACSIM_BASE_IMAGE_ARG
ARG ISAACSIM_VERSION_ARG
FROM ${ISAACSIM_BASE_IMAGE_ARG}:${ISAACSIM_VERSION_ARG} AS base
ENV ISAACSIM_VERSION=${ISAACSIM_VERSION_ARG}

# Set default RUN shell to bash
SHELL ["/bin/bash", "-c"]

# Adds labels to the Dockerfile
LABEL version="2.1.1"
LABEL description="Dockerfile for building and running the Isaac Lab framework inside Isaac Sim container image."

# Arguments
# Path to Isaac Sim root folder
ARG ISAACSIM_ROOT_PATH_ARG
ENV ISAACSIM_ROOT_PATH=${ISAACSIM_ROOT_PATH_ARG}
# Path to the Isaac Lab directory
ARG ISAACLAB_PATH_ARG
ENV ISAACLAB_PATH=${ISAACLAB_PATH_ARG}
# Home dir of the runtime docker user, typically '/root'
ARG DOCKER_USER_HOME_ARG
ENV DOCKER_USER_HOME=${DOCKER_USER_HOME_ARG}
ENV HOME=${DOCKER_USER_HOME}

# Set environment variables
ENV LANG=C.UTF-8
ENV DEBIAN_FRONTEND=noninteractive

# Base image may end with a non-root user; switch to root for system-level
# setup and package installation.
USER root

# Install dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    build-essential \
    libglib2.0-0 \
    ncurses-term \
    cmake \
    git \
    wget

# arm64-only build deps:
# - imgui-bundle has no prebuilt arm64 wheel; needs GL/X11 dev headers.
RUN if [ "$(dpkg --print-architecture)" = "arm64" ]; then \
        apt-get update && \
        apt-get install -y --no-install-recommends \
        libgl1-mesa-dev libopengl-dev libglx-dev \
        libx11-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev; \
    fi

# Detect Ubuntu version and install CUDA 12.8 via NVIDIA network repo (cuda-keyring)
RUN set -euo pipefail && \
    . /etc/os-release && \
    case "$ID" in \
      ubuntu) \
        case "$VERSION_ID" in \
          "20.04") cuda_repo="ubuntu2004";; \
          "22.04") cuda_repo="ubuntu2204";; \
          "24.04") cuda_repo="ubuntu2404";; \
          *) echo "Unsupported Ubuntu $VERSION_ID"; exit 1;; \
        esac ;; \
      *) echo "Unsupported base OS: $ID"; exit 1 ;; \
    esac && \
    apt-get update && apt-get install -y --no-install-recommends wget gnupg ca-certificates && \
    wget -q https://developer.download.nvidia.com/compute/cuda/repos/${cuda_repo}/x86_64/cuda-keyring_1.1-1_all.deb && \
    dpkg -i cuda-keyring_1.1-1_all.deb && \
    rm -f cuda-keyring_1.1-1_all.deb && \
    wget -q https://developer.download.nvidia.com/compute/cuda/repos/${cuda_repo}/x86_64/cuda-${cuda_repo}.pin && \
    mv cuda-${cuda_repo}.pin /etc/apt/preferences.d/cuda-repository-pin-600 && \
    apt-get update && \
    apt-get install -y --no-install-recommends \
        cuda-toolkit-12-8 \
        libcudnn9-cuda-12 \
        libcusparselt0 \
        libnccl2 \
        libnccl-dev \
        libnvjitlink-12-8 && \
    apt-get -y autoremove && apt-get clean && rm -rf /var/lib/apt/lists/*


ENV CUDA_HOME=/usr/local/cuda-12.8
ENV PATH=${CUDA_HOME}/bin:${PATH}
ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
ENV TORCH_CUDA_ARCH_LIST=8.0+PTX

# copy files necessary for installing Isaac Lab and its dependencies
# this way we minimize the chance of cache invalidation on file edits
COPY ../isaaclab.* ../environment.yml ../pyproject.toml ${ISAACLAB_PATH}/
COPY ../tools/ ${ISAACLAB_PATH}/tools/
COPY ../source/ ${ISAACLAB_PATH}/source/

# Fix the line endings for the shell scripts (Windows git may add \r)
RUN find ${ISAACLAB_PATH} -type f -name "*.sh" -exec sed -i 's/\r$//' {} +

# Ensure isaaclab.sh has execute permissions
RUN chmod +x ${ISAACLAB_PATH}/isaaclab.sh

# Set up a symbolic link between the installed Isaac Sim root folder and _isaac_sim in the Isaac Lab directory
RUN ln -sf ${ISAACSIM_ROOT_PATH} ${ISAACLAB_PATH}/_isaac_sim

# Install toml dependency
RUN ${ISAACLAB_PATH}/isaaclab.sh -p -m pip install toml

# Install apt dependencies for extensions that declare them in their extension.toml,
RUN ${ISAACLAB_PATH}/isaaclab.sh -p ${ISAACLAB_PATH}/tools/install_deps.py apt ${ISAACLAB_PATH}/source && \
    apt-get -y autoremove && apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# for singularity usage, have to create the directories that will binded
RUN mkdir -p ${ISAACSIM_ROOT_PATH}/kit/cache && \
    mkdir -p ${DOCKER_USER_HOME}/.cache/ov && \
    mkdir -p ${DOCKER_USER_HOME}/.cache/pip && \
    mkdir -p ${DOCKER_USER_HOME}/.cache/nvidia/GLCache &&  \
    mkdir -p ${DOCKER_USER_HOME}/.nv/ComputeCache && \
    mkdir -p ${DOCKER_USER_HOME}/.nvidia-omniverse/logs && \
    mkdir -p ${DOCKER_USER_HOME}/.local/share/ov/data && \
    mkdir -p ${DOCKER_USER_HOME}/Documents

# for singularity usage, create NVIDIA binary placeholders
RUN touch /bin/nvidia-smi && \
    touch /bin/nvidia-debugdump && \
    touch /bin/nvidia-persistenced && \
    touch /bin/nvidia-cuda-mps-control && \
    touch /bin/nvidia-cuda-mps-server && \
    touch /etc/localtime && \
    mkdir -p /var/run/nvidia-persistenced && \
    touch /var/run/nvidia-persistenced/socket

# HACK: Remove pre-bundled torch BEFORE installing Isaac Lab dependencies.
# This forces isaaclab.sh --install to install torch fresh to site-packages,
# rather than skipping because it detects the pre-bundled version.
RUN rm -rf ${ISAACSIM_ROOT_PATH}/exts/omni.isaac.ml_archive/pip_prebundle/torch*

# HACK: Reinstall pip properly after removing prebundled packages
# The removal of torch* corrupts pip's vendor packages (_structures.py is deleted).
# We must completely remove pip first, then do a clean install.
RUN rm -rf ${ISAACSIM_ROOT_PATH}/kit/python/lib/python3.12/site-packages/pip* && \
    wget -q https://bootstrap.pypa.io/get-pip.py && \
    ${ISAACLAB_PATH}/_isaac_sim/kit/python/bin/python3 get-pip.py && \
    rm get-pip.py

RUN --mount=type=cache,target=${DOCKER_USER_HOME}/.cache/pip \
    ${ISAACLAB_PATH}/isaaclab.sh --install

# HACK: Uninstall quadprog as it causes issues with some reinforcement learning frameworks
RUN ${ISAACLAB_PATH}/isaaclab.sh -p -m pip uninstall -y quadprog

# Install cuRobo from source (pinned commit); needs CUDA env and Torch
RUN ${ISAACLAB_PATH}/isaaclab.sh -p -m pip install --no-build-isolation \
    "nvidia-curobo @ git+https://github.com/NVlabs/curobo.git@ebb71702f3f70e767f40fd8e050674af0288abe8"

# Install isaaclab_teleop (needed by Pink IK tests and related env configs)
RUN ${ISAACLAB_PATH}/isaaclab.sh -p -m pip install --editable ${ISAACLAB_PATH}/source/isaaclab_teleop

# aliasing isaaclab.sh and python for convenience
RUN echo "export ISAACLAB_PATH=${ISAACLAB_PATH}" >> ${DOCKER_USER_HOME}/.bashrc && \
    echo "alias isaaclab=${ISAACLAB_PATH}/isaaclab.sh" >> ${DOCKER_USER_HOME}/.bashrc && \
    echo "alias python=${ISAACLAB_PATH}/_isaac_sim/python.sh" >> ${DOCKER_USER_HOME}/.bashrc && \
    echo "alias python3=${ISAACLAB_PATH}/_isaac_sim/python.sh" >> ${DOCKER_USER_HOME}/.bashrc && \
    echo "alias pip='${ISAACLAB_PATH}/_isaac_sim/python.sh -m pip'" >> ${DOCKER_USER_HOME}/.bashrc && \
    echo "alias pip3='${ISAACLAB_PATH}/_isaac_sim/python.sh -m pip'" >> ${DOCKER_USER_HOME}/.bashrc && \
    echo "alias tensorboard='${ISAACLAB_PATH}/_isaac_sim/python.sh ${ISAACLAB_PATH}/_isaac_sim/tensorboard'" >> ${DOCKER_USER_HOME}/.bashrc && \
    echo "export TZ=$(date +%Z)" >> ${DOCKER_USER_HOME}/.bashrc && \
    echo "shopt -s histappend" >> ${DOCKER_USER_HOME}/.bashrc && \
    echo "PROMPT_COMMAND='history -a'" >> ${DOCKER_USER_HOME}/.bashrc

# Create the non-root runtime user after root-only image setup is complete.
# The uid/gid 1000 match GitHub runner bind mounts used by the cuRobo tests.
# --non-unique is required because some base image revisions already carry
# another user or group at uid/gid 1000.
RUN groupadd --non-unique --gid 1000 isaaclab \
 && useradd --non-unique --uid 1000 --gid 1000 -M -l -s /bin/bash -d ${DOCKER_USER_HOME} isaaclab

RUN chown -R isaaclab:isaaclab \
        ${ISAACLAB_PATH} \
        ${DOCKER_USER_HOME}

# Open up traversal of the Isaac Sim root and runtime home for non-root users.
# Inner Isaac Sim files keep their original permissions, so avoid chowning the
# full install. Keep the runtime home closed to unrelated users.
RUN chmod 755 \
        ${ISAACSIM_ROOT_PATH} \
 && chmod 750 \
        ${DOCKER_USER_HOME}

# copy the rest of the files
COPY --chown=isaaclab:isaaclab ../ ${ISAACLAB_PATH}/

# Pre-create every docker-compose named-volume mount point and hand it to the
# non-root runtime user. docker-compose.yaml is the single source of truth for
# the list; docker/utils/volume_mounts.py parses it so the paths are not
# duplicated here. A fresh named volume inherits ownership from the image
# directory at its mount path; if that directory is missing or root-owned, the
# volume comes up root-owned and the isaaclab user cannot write it (e.g.
# PermissionError creating logs/, or omni.datastore lock failures under
# kit/cache). set -o pipefail makes a parse failure abort the build:
# volume_mounts.py exits non-zero on an empty/unresolved list and grep exits
# non-zero if no paths are produced, so the build fails here rather than
# silently shipping an unprepared mount point.
RUN set -o pipefail \
 && export DOCKER_ISAACSIM_ROOT_PATH="${ISAACSIM_ROOT_PATH}" \
           DOCKER_ISAACLAB_PATH="${ISAACLAB_PATH}" \
           DOCKER_USER_HOME="${DOCKER_USER_HOME}" \
 && dirs="$(${ISAACLAB_PATH}/isaaclab.sh -p ${ISAACLAB_PATH}/docker/utils/volume_mounts.py | grep '^/')" \
 && mkdir -p ${dirs} \
 && chown -R isaaclab:isaaclab ${dirs}

USER isaaclab

# make working directory as the Isaac Lab directory
# this is the default directory when the container is run
WORKDIR ${ISAACLAB_PATH}