Skip to content

Commit

Permalink
Merge pull request #118 from cs50/docker
Browse files Browse the repository at this point in the history
Adds support for Docker outside of Docker
  • Loading branch information
dmalan authored Jan 29, 2024
2 parents 91551b3 + cb585f5 commit 69ed47a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions cli50/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def main():
"--security-opt", "seccomp=unconfined", # https://stackoverflow.com/q/35860527#comment62818827_35860527, https://github.com/apple/swift-docker/issues/9#issuecomment-328218803
"--tty",
"--volume", directory + ":" + workdir,
"--volume", "/var/run/docker.sock:/var/run/docker-host.sock", # https://github.com/devcontainers/features/blob/main/src/docker-outside-of-docker/devcontainer-feature.json
"--workdir", workdir]

# Check for locale
Expand Down Expand Up @@ -259,6 +260,13 @@ def main():
["--publish-all"] +
[f"{IMAGE}:{args['tag']}"] + cmd).decode("utf-8").rstrip()

# Start Docker-outside-of-Docker (if supported by TAG)
# a la https://github.com/devcontainers/features/blob/main/src/docker-outside-of-docker/install.sh
try:
subprocess.check_output(["docker", "exec", container, "sudo", "/etc/init.d/docker", "start"])
except subprocess.CalledProcessError:
pass

# List port mappings
print(ports(container))

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"console_scripts": ["cli50=cli50.__main__:main"]
},
url="https://github.com/cs50/cli50",
version="7.4.1",
version="7.5.0",
include_package_data=True
)

0 comments on commit 69ed47a

Please sign in to comment.