-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from cs50/docker
Adds support for Docker outside of Docker
- Loading branch information
Showing
4 changed files
with
63 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# Adapted from https://github.com/devcontainers/features/blob/main/src/docker-outside-of-docker/install.sh. | ||
# If docker-ce is installed, shadows its own. | ||
|
||
SOURCE_SOCKET=/var/run/docker-host.sock | ||
TARGET_SOCKET=/var/run/docker.sock | ||
SOCAT_PID=/tmp/docker.pid | ||
|
||
case "$1" in | ||
start) | ||
echo "Starting Docker" | ||
socat UNIX-LISTEN:${TARGET_SOCKET},fork,group=docker,mode=660 UNIX-CONNECT:${SOURCE_SOCKET} & echo "$!" > "$SOCAT_PID" | ||
;; | ||
stop) | ||
echo "Stopping Docker" | ||
kill -9 $(cat "$SOCAT_PID" 2> /dev/null) 2> /dev/null | ||
rm --force "$SOCAT_PID" "$TARGET_SOCKET" | ||
;; | ||
restart) | ||
$0 stop | ||
$0 start | ||
;; | ||
status) | ||
if [[ ! -f "${SOCAT_PID}" ]] || ! ps -p $(cat "$SOCAT_PID" 2> /dev/null) &> /dev/null; then | ||
echo "Docker is not running" | ||
exit 1 | ||
else | ||
echo "Docker is running" | ||
exit 0 | ||
fi | ||
;; | ||
*) | ||
echo "Usage: $0 {start|stop|restart|status}" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters