Skip to content

Commit

Permalink
Merge pull request #294 from ICRAR/docker_fix
Browse files Browse the repository at this point in the history
Docker fix
  • Loading branch information
myxie authored Nov 14, 2024
2 parents c09b85e + e29e7ad commit 4c5138c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions daliuge-engine/dlg/apps/dockerapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def waitForIp(self, timeout=None):
# @param image /String/ComponentParameter/NoPort/ReadWrite//False/False/The name of the docker image to be used for this application
# @param docker_tag 1.0/String/ComponentParameter/NoPort/ReadWrite//False/False/The tag of the docker image to be used for this application
# @param docker_digest /String/ComponentParameter/NoPort/ReadWrite//False/False/The hexadecimal hash (long version) of the docker image to be used for this application
# @param command /String/ComponentParameter/NoPort/ReadWrite//False/False/The command line to run within the docker instance. The specified command will be executed in a bash shell. That means that images will need a bash shell.
# @param command /String/ComponentParameter/NoPort/ReadWrite//False/False/The command line to run within the docker instance. Leave empty to execute the default command specified as the entrypoint of the image.
# @param input_redirection /String/ComponentParameter/NoPort/ReadWrite//False/False/The command line argument that specifies the input into this application
# @param output_redirection /String/ComponentParameter/NoPort/ReadWrite//False/False/The command line argument that specifies the output from this application
# @param command_line_arguments /String/ComponentParameter/NoPort/ReadWrite//False/False/Additional command line arguments to be added to the command line to be executed
Expand Down Expand Up @@ -250,7 +250,7 @@ def initialize(self, **kwargs):
self._applicationArgs = self._popArg(kwargs, "applicationArgs", {})
self._argumentPrefix = self._popArg(kwargs, "argumentPrefix", "--")
self._paramValueSeparator = self._popArg(kwargs, "paramValueSeparator", " ")
self._entryPoint = self._popArg(kwargs, "entrypoint", " ")
self._entryPoint = self._popArg(kwargs, "entrypoint", None)
if not self._image:
raise InvalidDropException(
self, "No docker image specified, cannot create DockerApp"
Expand Down Expand Up @@ -356,6 +356,7 @@ def initialize(self, **kwargs):
inspection = c.api.inspect_image(self._image)
logger.debug("Docker Image inspection: %r", inspection)
self.workdir = inspection.get("ContainerConfig", {}).get("WorkingDir", None)
self.defaultEntryPoint = inspection.get("Config", {}).get("Entrypoint", None)
# self.workdir = None
self._sessionId = self._dlg_session_id
if not self.workdir:
Expand Down Expand Up @@ -554,15 +555,17 @@ def run(self):

# Wrap everything inside bash
if len(cmd) > 0 and not self._noBash:
cmd = (
self._entryPoint = (
'/bin/bash -c "%s"'
% (utils.escapeQuotes(cmd, singleQuotes=False)).strip()
)
logger.info("Command after user creation and wrapping is: %s", cmd)
else:
cmd = f"{utils.escapeQuotes(cmd, singleQuotes=False)}".strip()
# cmd = f"{utils.escapeQuotes(cmd, singleQuotes=False)}".strip()
# cmd = cmd.split(" ")
logger.info(
"executing container with default cmd and wrapped arguments: %s",
"executing container with default cmd %s and wrapped arguments: %s",
self.defaultEntryPoint,
cmd,
)

Expand All @@ -583,7 +586,7 @@ def run(self):
# TODO: daliuge will handle automatic removal (otherwise check before stopping container)
# auto_remove=self._removeContainer,
detach=True,
entrypoint=f"{self._entryPoint}",
entrypoint=f"{self._entryPoint}" if self._entryPoint else None,
)

if not self.container:
Expand Down

0 comments on commit 4c5138c

Please sign in to comment.