From a9532d633765906697a42807e69816b009a1a04b Mon Sep 17 00:00:00 2001 From: Magno Costa Date: Wed, 10 Jul 2024 15:03:30 -0300 Subject: [PATCH] [REF] Adapted 'docky open' command for Docker Compose V2. --- docky/cmd/run_open.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docky/cmd/run_open.py b/docky/cmd/run_open.py index 562142c..9813e81 100644 --- a/docky/cmd/run_open.py +++ b/docky/cmd/run_open.py @@ -3,6 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). import sys +import subprocess from plumbum import cli from .base import Docky, DockySub from ..common.api import raise_error, logger @@ -81,7 +82,24 @@ class DockyOpen(DockyExec): def _main(self, *optionnal_command_line): super()._main(*optionnal_command_line) - self._exec("dcpatched", ["exec", "-e", "NOGOSU=True", self.service] + self.cmd) + # self._exec("dcpatched", ["exec", "-e", "NOGOSU=True", self.service] + self.cmd) + + # Get Project Name + # Example: docky-odoo-brasil-14 odoo + project_name = self.project.name + "-" + self.project.service + + # Get User + user = self._use_specific_user(self.service) + + # Get Container ID + command = "docker ps -aqf name=" + project_name + # Example of return value + # b'b5db9db21381\n' + # Option text=true return as string instead of bytes and strip remove break line + # TODO: Is there a better way to do it, for example with Plumbum? + container_id = subprocess.check_output(command, shell=True,text=True).strip() + + self._exec("docker", ["exec", "-u", user, "-it", container_id, "/bin/bash"]) @Docky.subcommand("system") class DockySystem(DockyExec):