Skip to content

Commit 62137c1

Browse files
committed
Add support for giving devcontainer access to parent docker socket to allow nested Docker containers (for tests etc)
1 parent 95a1080 commit 62137c1

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

.dockerignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.github/*
33
.idea/*
44
.vscode/*
5-
docker/*
65
.git/*
7-
target/*
6+
target/*
7+
docker/Dockerfile
8+
docker/docker-compose.yaml

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ RUN groupadd --gid $GID $USERNAME \
3939
# Set the ownership of the overlay workspace to the new user
4040
RUN chown -R ${UID}:${GID} /ws
4141

42-
RUN groupadd fuse \
42+
RUN groupadd fuse\
4343
&& usermod -aG fuse,video ${USERNAME}
4444

4545
# Set the user and source entrypoint in the user's .bashrc file

docker/docker-compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ services:
1212
- /tmp/.X11-unix:/tmp/.X11-unix:rw
1313
- ${XAUTHORITY:-$HOME/.Xauthority}:/root/.Xauthority
1414
- /dev/shm:/dev/shm
15+
- /var/run/docker.sock:/var/run/docker.sock
1516
environment:
1617
- DISPLAY=${DISPLAY}
1718
network_mode: host

docker/entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ then
1212
# echo "Sourced TurtleBot4 base workspace"
1313
fi
1414

15+
sudo groupadd -g $(stat -c "%g" /var/run/docker.sock) docker &> /dev/null
16+
sudo usermod -aG docker $(id -nu)
17+
1518
# if [ "$EUID" -gt 0 ]; then
1619
# sudo chown -R ${UID}:${UID} ~/.ros
1720
# sudo chown -R ${UID}:${UID} ~/.ignition

0 commit comments

Comments
 (0)