Skip to content

Commit 99c40a5

Browse files
committed
feat: change to user to non-root
1 parent 67f267f commit 99c40a5

File tree

3 files changed

+67
-66
lines changed

3 files changed

+67
-66
lines changed

docker/Dockerfile.isaacsim-humble

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ RUN curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | a
2121
RUN apt-get update && apt-get install -y \
2222
ros-$ROS_DISTRO-desktop \
2323
python3-colcon-common-extensions \
24-
ros-$ROS_DISTRO-cyclonedds* \
24+
ros-$ROS_DISTRO-rmw-cyclonedds-cpp \
2525
&& rm -rf /var/lib/apt/lists/*
2626

2727
# Source ROS 2 setup file

docker/Dockerfile.stridesim

+20-41
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,34 @@
11
FROM isaac-sim-ros2:humble-4.0.0
22

3-
# Set working directory to root
4-
WORKDIR /
3+
# 빌드 인자 선언
4+
ARG USERNAME
5+
ARG USERPASSWORD
56

6-
# Update apt-get and install necessary packages
7+
# Update apt-get, install necessary packages, and set up build tools
78
RUN apt-get update && \
8-
apt-get install -y git curl git-lfs cmake && \
9-
git lfs install
10-
11-
# install build tools
12-
RUN apt-get install -y build-essential gcc g++ sudo wget unzip software-properties-common
13-
14-
# Clone the required repositories
15-
RUN git clone https://github.com/AuTURBO/StrideSim.git && \
16-
git clone https://github.com/isaac-sim/IsaacLab.git -b v1.0.0
9+
apt-get install -y \
10+
git curl git-lfs cmake \
11+
build-essential gcc g++ sudo wget unzip software-properties-common python3-pip && \
12+
git lfs install && \
13+
apt-get clean && \
14+
rm -rf /var/lib/apt/lists/*
1715

18-
# pull lfs files in StrideSim
19-
WORKDIR /StrideSim
20-
21-
RUN git lfs fetch && \
22-
git lfs pull
16+
RUN git clone https://github.com/isaac-sim/IsaacLab.git -b v1.0.0
2317

2418
# Set up IsaacLab
2519
WORKDIR /IsaacLab
20+
RUN TERM=xterm-256color ln -s /isaac-sim _isaac_sim && \
21+
TERM=xterm-256color /bin/bash -c "./isaaclab.sh --install"
2622

27-
# Create symbolic link
28-
RUN ln -s /isaac-sim _isaac_sim
29-
30-
# Install IsaacLab
31-
ENV TERM=xterm-256color
32-
RUN /bin/bash -c "./isaaclab.sh --install"
23+
RUN useradd -m $USERNAME
3324

34-
# Set up StrideSim
35-
WORKDIR /StrideSim/rl
25+
# 인자로 받은 USERPASSWORD 로 비밀번호 설정
26+
RUN echo "$USERNAME:$USERPASSWORD" | chpasswd
3627

37-
RUN apt-get install -y python3-pip
28+
RUN usermod -aG sudo $USERNAME
3829

39-
# Create symbolic link for python3 to python
40-
RUN ln -s /usr/bin/python3 /usr/bin/python
41-
42-
RUN /bin/bash -c "python -m pip install -e ."
43-
44-
WORKDIR /isaac-sim
45-
46-
# Create a non-root admin user
47-
RUN useradd -m -s /bin/bash -G sudo user && \
48-
echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
49-
chown -R user:user /isaac-sim /StrideSim /IsaacLab
50-
51-
# Switch to user
52-
USER user
30+
USER $USERNAME
31+
WORKDIR /
5332

5433
# Set default shell to bash
55-
SHELL ["/bin/bash", "-c"]
34+
SHELL ["/bin/bash", "-c"]

docker/README.md

+46-24
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,33 @@ docker pull nvcr.io/nvidia/isaac-sim:4.0.0
8989

9090
## Run StrideSim Docker Container
9191

92+
First, set the environment variables to build Docker Image.
93+
94+
```bash
95+
export StrideSim_DIR=${PWD}
96+
export StrideSim_NAME=$(whoami)-docker
97+
export StrideSim_PASSWORD=a
98+
```
99+
92100
1. Build Docker Image
93101

94102
First, you need to make base image.
95103

96104
```bash
97105
cd ${StrideSim_DIR}
98-
docker build -t isaac-sim-ros2:humble-4.0.0 -f docker/Dockerfile.isaacsim-humble .
106+
docker build -t isaac-sim-ros2:humble-4.0.0 \
107+
--build-arg ROS_DISTRO=humble \
108+
-f docker/Dockerfile.isaacsim-humble .
99109
```
100110

101111
Then, build StrideSim Docker Image.
102112

103113
```bash
104114
cd ${StrideSim_DIR}
105-
docker build -t stride-sim:v0.0.2 -f docker/Dockerfile.stridesim .
115+
docker build -t stride-sim:v0.0.3 \
116+
--build-arg USERNAME=${StrideSim_NAME} \
117+
--build-arg USERPASSWORD=${StrideSim_PASSWORD} \
118+
-f docker/Dockerfile.stridesim .
106119
```
107120

108121
> The reason why we need to build base image is to reduce the build time.
@@ -112,7 +125,7 @@ docker build -t stride-sim:v0.0.2 -f docker/Dockerfile.stridesim .
112125
Then, you can run StrideSim Docker Container.
113126

114127
```bash
115-
docker run --name stride-sim-0.0.2 --entrypoint bash -it --runtime=nvidia --gpus all -e "ACCEPT_EULA=Y" --network=host --privileged \
128+
docker run --name stride-sim-0.0.3 --entrypoint bash -it --runtime=nvidia --gpus all -e "ACCEPT_EULA=Y" --network=host --privileged \
116129
-e DISPLAY=$DISPLAY \
117130
-e OMNI_KIT_ALLOW_ROOT=1 \
118131
-e RMW_IMPLEMENTATION=rmw_cyclonedds_cpp \
@@ -128,8 +141,14 @@ docker run --name stride-sim-0.0.2 --entrypoint bash -it --runtime=nvidia --gpus
128141
-v ~/docker/isaac-sim/logs:/root/.nvidia-omniverse/logs:rw \
129142
-v ~/docker/isaac-sim/data:/root/.local/share/ov/data:rw \
130143
-v ~/docker/isaac-sim/documents:/root/Documents:rw \
144+
-v ${StrideSim_DIR}:/StrideSim:rw \
131145
-v /dev/shm:/dev/shm \
132-
stride-sim:v0.0.2
146+
stride-sim:v0.0.3
147+
```
148+
149+
```bash
150+
# It takes a long time to run the first time about 3 minutes.
151+
sudo chmod 777 -R /isaac-sim
133152
```
134153

135154
Now you can run StrideSim Docker Container.
@@ -140,25 +159,7 @@ You can run the following command to run isaac-sim.
140159

141160
```bash
142161
cd /isaac-sim
143-
./isaac-sim.sh --allow-root
144-
```
145-
146-
1. Get ROS2 Topic from StrideSim
147-
148-
The StrideSim container runs with administrative privileges. To receive ROS2 messages published by processes within this container, administrative permissions are required. You can choose one of the following methods, command below in host environment:
149-
150-
* Use an administrator prompt.
151-
152-
```
153-
$ sudo su
154-
# source /opt/ros/humble/setup.bash
155-
# ros2 topic list
156-
```
157-
158-
* Set permissions for /dev/shm.
159-
160-
```
161-
$ sudo chmod -R 777 /dev/shm
162+
./isaac-sim.sh
162163
```
163164

164165
ENJOY!
@@ -206,7 +207,28 @@ rm -rf ~/docker/isaac-sim/cache/*
206207

207208
2. Run with reduced graphics settings:
208209
```bash
209-
./isaac-sim.sh --allow-root --headless
210+
./isaac-sim.sh --headless
210211
```
211212

212213
*Back to [README](../README.md)*
214+
215+
216+
## Deprecated
217+
218+
1. Get ROS2 Topic from StrideSim
219+
220+
The StrideSim container runs with administrative privileges. To receive ROS2 messages published by processes within this container, administrative permissions are required. You can choose one of the following methods, command below in host environment:
221+
222+
* Use an administrator prompt.
223+
224+
```
225+
$ sudo su
226+
# source /opt/ros/humble/setup.bash
227+
# ros2 topic list
228+
```
229+
230+
* Set permissions for /dev/shm.
231+
232+
```
233+
$ sudo chmod -R 777 /dev/shm
234+
```

0 commit comments

Comments
 (0)