Solution skill
WITH DOCKER using compose gives "Project name not found"
Complete solution
Shows how to fix wITH DOCKER using compose gives "Project name not found". Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
If WITH DOCKER --compose in your Earthfile suddenly fails with 'project name must not be empty' in CI, the reporter's workaround was to add a WORKDIR in the target itself, e.g. WORKDIR /root before the COPY of the compose file.
Steps
- If WITH DOCKER --compose in your Earthfile suddenly fails with 'project name must not be empty' in CI, the reporter's workaround was to add a WORKDIR in the target itself, e.g. WORKDIR /root before the COPY of the compose file. Example: repro: FROM earthly/dind:alpine, WORKDIR /root, COPY docker-compose-x.yml ., then WITH DOCKER --pull postgres --compose docker-compose-x.yml --service db.
- Source: https://github.com/earthly/earthly/issues/3164 (Earthly)
When to use
You are seeing this: WORKDIR /root before the COPY of the compose file. Use this skill when you run into "WITH DOCKER using compose gives "Project name not found"".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://github.com/earthly/earthly/issues/3164
Evidence
In gh:earthly/earthly#3164, the issue was: What went wrong? [!-- Can you describe what happened? --]
A previously working use of WITH DOCKER with --compose in our Earthfile has suddenly begun failing in our CI runs with a project name must not be empty error:
> earthly --verbose +repro
frontend | Running command: docker info
frontend | Running command: docker info --format={{.SecurityOptions}}
frontend | Running command: docker info --format={{.DockerRootDir}}
frontend | docker-shell frontend initialized.
Init.... The verified answer: If WITH DOCKER --compose in your Earthfile suddenly fails with 'project name must not be empty' in CI, the reporter's workaround was to add a WORKDIR in the target itself, e.g. WORKDIR /root before the COPY of the compose file. Example: repro: FROM earthly/dind:alpine, WORKDIR /root, COPY docker-compose-x.yml ., then WITH DOCKER --pull postgres --compose docker-compose-x.yml --service db.. Issue URL: https://github.com/earthly/earthly/issues/3164By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_JokxD5MoXhkhkHS7W36bEg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">WITH DOCKER using compose gives "Project name not found" <span>— Vectle</span></a>