kubernetes / kubernetes/kompose
[BUG] kompose crashes on simple docker-compose.yml with name: top-level element
- Dominant language
- Go
- Stars
- 10.6k
- Forks
- 816
- PR merge metrics
- No merged PRs in 30d
Description
### Expected Behavior
I was testing `kompose` (installed via Ubuntu 24 snap); the program doesn't show any version information.
I'm using the example from the [docker documentation](https://docs.docker.com/reference/compose-file/version-and-name/#name-top-level-element):
```
$ cat docker-compose.yml
name: myapp
services:
foo:
image: busybox
command: echo "I'm running ${COMPOSE_PROJECT_NAME}"
```
which results in
```
$ kompose convert -f docker-compose.yml -o k8s
ERRO Could not parse config for project test : yaml: unmarshal errors:
line 1: cannot unmarshal !!str `myapp` into config.RawService
FATA composeObject.Parse() failed, Failed to load compose file: yaml: unmarshal errors:
line 1: cannot unmarshal !!str `myapp` into config.RawService
```
Removing the `name` and the reference to `COMPOSE_PROJECT_NAME` results in:
```
ERRO Could not parse config for project test : Unsupported config option for services service: 'foo'
FATA composeObject.Parse() failed, Failed to load compose file: Unsupported config option for services service: 'foo'
```
Running the docker-compose through `docker compose config` also fails.
### Actual Behavior
It should handle at least simple examples from the docker compose documentation correctly. ChatGPT recommended kompose, but so far it failed on all examples I tried.
### Steps To Reproduce
_No response_
### Kompose Version
```Text
1.21.0 (992df58d8)
```
### Docker-Compose file
```YAML
name: myapp
services:
foo:
image: busybox
command: echo "I'm running ${COMPOSE_PROJECT_NAME}"
```
### Anything else?
Contributor guide
Research direction
Start by reproducing the failure with the provided docker-compose.yml using `kompose convert -f docker-compose.yml -o k8s`, then trace the `composeObject.Parse()` configuration-loading path named in the error. Done means the documented `name` and `services` example parses successfully and converts to Kubernetes output without the reported unmarshalling or unsupported-option errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker-compose, go
- Domain
- cli, devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100