Skip to content

Commit 8de0dfd

Browse files
committed
[REF] Adapted 'docky open' command for Docker Compose V2.
1 parent 0c8a640 commit 8de0dfd

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

docky/cmd/run_open.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# @author Sébastien BEAU <[email protected]>
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
44

5+
import subprocess
56
from plumbum import cli
67
from .base import Docky, DockySub
78
from ..common.api import raise_error
@@ -78,7 +79,24 @@ class DockyOpen(DockyExec):
7879

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

83101
@Docky.subcommand("system")
84102
class DockySystem(DockyExec):

0 commit comments

Comments
 (0)