Skip to content

Commit 96122e9

Browse files
committed
[REF] Adapted 'docky open' command for Docker Compose V2.
1 parent fe0fcf7 commit 96122e9

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

docky/cmd/run_open.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
44

55
import sys
6+
import subprocess
67
from plumbum import cli
78
from .base import Docky, DockySub
89
from ..common.api import raise_error, logger
@@ -81,7 +82,24 @@ class DockyOpen(DockyExec):
8182

8283
def _main(self, *optionnal_command_line):
8384
super()._main(*optionnal_command_line)
84-
self._exec("dcpatched", ["exec", "-e", "NOGOSU=True", self.service] + self.cmd)
85+
# self._exec("dcpatched", ["exec", "-e", "NOGOSU=True", self.service] + self.cmd)
86+
87+
# Get Project Name
88+
# Example: docky-odoo-brasil-14 odoo
89+
project_name = self.project.name + "-" + self.project.service
90+
91+
# Get User
92+
user = self._use_specific_user(self.service)
93+
94+
# Get Container ID
95+
command = "docker ps -aqf name=" + project_name
96+
# Example of return value
97+
# b'b5db9db21381\n'
98+
# Option text=true return as string instead of bytes and strip remove break line
99+
# TODO: Is there a better way to do it, for example with Plumbum?
100+
container_id = subprocess.check_output(command, shell=True,text=True).strip()
101+
102+
self._exec("docker", ["exec", "-u", user, "-it", container_id, "/bin/bash"])
85103

86104
@Docky.subcommand("system")
87105
class DockySystem(DockyExec):

0 commit comments

Comments
 (0)