Skip to content

fix(up): allow entrypoint and command together, place --entrypoint before image#80

Open
Cyb3rDudu wants to merge 2 commits intoMcrich23:mainfrom
Cyb3rDudu:fix/entrypoint-command-translation
Open

fix(up): allow entrypoint and command together, place --entrypoint before image#80
Cyb3rDudu wants to merge 2 commits intoMcrich23:mainfrom
Cyb3rDudu:fix/entrypoint-command-translation

Conversation

@Cyb3rDudu
Copy link
Copy Markdown
Contributor

@Cyb3rDudu Cyb3rDudu commented May 4, 2026

Compose files using entrypoint: ["/bin/bash","-c"] (or sh) plus a multi-line command: heredoc silently drop the command: part — the script never runs:

services:
  web:
    image: httpd:2.4
    entrypoint: ["/bin/bash", "-c"]
    command:
      - |
        sed -i "s|Listen 80|Listen 8080|" /usr/local/apache2/conf/httpd.conf
        exec httpd-foreground

Two bugs in ComposeUp.swift::configService:

  1. entrypoint and command go through an else if, so setting both means command is dropped.
  2. --entrypoint is appended after the image and gets every entrypoint element — but container run --entrypoint only takes one binary.

Fix pulls the translation into a static helper:

  • First entrypoint element → --entrypoint <bin> (before the image)
  • Rest of entrypoint + every command element → positional args after the image

Tests: 8 static cases for the helper covering all combinations (nil/empty/single/multi entrypoint × nil/command, including the bash-c heredoc shape from #77), plus one dynamic test that runs sh -c with a multi-line script and asserts the container is actually running afterward.

Fixes #77.

Cyb3rDudu added 2 commits May 4, 2026 11:25
…fore image

Compose semantics treat `entrypoint` and `command` as composable: `entrypoint`
replaces the image's ENTRYPOINT, `command` becomes its argv tail. The current
code makes them mutually exclusive (`else if`) and appends `--entrypoint` plus
all entrypoint elements *after* the image, so:

  entrypoint: ["/bin/bash", "-c"]
  command:
    - |
      sed -i ... /etc/httpd.conf
      exec httpd-foreground

silently drops `command`, and `container run` only takes one executable for
`--entrypoint` anyway.

This pulls the translation into a static helper:
- first `entrypoint` element → `--entrypoint <bin>` (before the image)
- rest of `entrypoint` + every `command` element → positional args after the image

Fixes Mcrich23#77.
8 static cases for the pure helper, including the bash -c heredoc shape
from Mcrich23#77. One dynamic test that runs sh -c with a multi-line script and
asserts the container is actually running afterward — on the buggy code,
command is dropped and sh exits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

entrypoint: ["/bin/bash","-c"] + multi-line command: produces broken arg passing

1 participant