Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'name' does not match any of the regexes: '^x-' #36

Open
ManuelB opened this issue Oct 24, 2024 · 6 comments · May be fixed by #38
Open

'name' does not match any of the regexes: '^x-' #36

ManuelB opened this issue Oct 24, 2024 · 6 comments · May be fixed by #38

Comments

@ManuelB
Copy link

ManuelB commented Oct 24, 2024

docker-compose --version
docker-compose version 1.29.2, build unknown

The docker-compose is the default one installed with apt install docker-compose on the most recent Ubuntu version oracular.

$ docker-compose -f dc-mocks.yml up
ERROR: The Compose file './dc-mocks.yml' is invalid because:
'name' does not match any of the regexes: '^x-'

You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

Adding a x- in front of name does solve this issue.

@KillerCodeMonkey
Copy link

KillerCodeMonkey commented Oct 29, 2024

@ManuelB

i had the same issue with docker-compose.

but please try the compose version integrated in docker

docker compose -f dc-mocks.yml up

For explanation: docker compose is based on docker-compose v2 code, docker-compose is just v1 and outdated

@sonerd
Copy link
Contributor

sonerd commented Oct 29, 2024

Thanks @KillerCodeMonkey for explanation. We didn't run into the issue as @ManuelB have mentioned. Cause we are using locally and in the CI environment the docker compose within the docker.

Can I close this issue?

@ManuelB
Copy link
Author

ManuelB commented Oct 29, 2024

@KillerCodeMonkey The proposed command is not working for me:

docker compose -f dc-mocks.yml up
unknown shorthand flag: 'f' in -f
See 'docker --help'.

Usage:  docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Common Commands:
  run         Create and run a new container from an image
  exec        Execute a command in a running container
  ps          List containers
  build       Build an image from a Dockerfile
  pull        Download an image from a registry
  push        Upload an image to a registry
  images      List images
  login       Log in to a registry
  logout      Log out from a registry
  search      Search Docker Hub for images
  version     Show the Docker version information
  info        Display system-wide information

Management Commands:
  builder     Manage builds
  buildx*     Docker Buildx
  container   Manage containers
  context     Manage contexts
  image       Manage images
  manifest    Manage Docker image manifests and manifest lists
  network     Manage networks
  plugin      Manage plugins
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes

Swarm Commands:
  swarm       Manage Swarm

Commands:
  attach      Attach local standard input, output, and error streams to a running container
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  import      Import the contents from a tarball to create a filesystem image
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  wait        Block until one or more containers stop, then print their exit codes

Global Options:
      --config string      Location of client config files (default "/home/manuel/.docker")
  -c, --context string     Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker
                           context use")
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket to connect to
  -l, --log-level string   Set the logging level ("debug", "info", "warn", "error", "fatal") (default "info")
      --tls                Use TLS; implied by --tlsverify
      --tlscacert string   Trust certs signed only by this CA (default "/home/manuel/.docker/ca.pem")
      --tlscert string     Path to TLS certificate file (default "/home/manuel/.docker/cert.pem")
      --tlskey string      Path to TLS key file (default "/home/manuel/.docker/key.pem")
      --tlsverify          Use TLS and verify the remote
  -v, --version            Print version information and quit

Run 'docker COMMAND --help' for more information on a command.

For more help on how to use Docker, head to https://docs.docker.com/go/guides/

@sonerd I will open a pull request with my suggested fix. Feel free to ignore it :-)

@sonerd
Copy link
Contributor

sonerd commented Oct 29, 2024

@ManuelB The reason why the command is not working on your machine, is that compose is missing in the management commands section.

When I execute docker --help I see following output for Management Commands:

Management Commands:
  builder     Manage builds
  buildx*     Docker Buildx
  compose*    Docker Compose
  container   Manage containers
  context     Manage contexts
  debug*      Get a shell into any image or container
  desktop*    Docker Desktop commands (Alpha)
  dev*        Docker Dev Environments
  extension*  Manages Docker extensions
  feedback*   Provide feedback, right in your terminal!
  image       Manage images
  init*       Creates Docker-related starter files for your project
  manifest    Manage Docker image manifests and manifest lists
  network     Manage networks
  plugin      Manage plugins
  sbom*       View the packaged-based Software Bill Of Materials (SBOM) for an image
  scout*      Docker Scout
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes

As you @KillerCodeMonkey said. You are not using the docker compose from the docker itself. So the fix would work for environments as yours but I am not sure, if it work for other environments.

@KillerCodeMonkey
Copy link

yeah but it is not that hard to follow the https://docs.docker.com/compose/install/ instructions :D.

in general just make sure you are using docker-compose v2 as standalone (https://docs.docker.com/compose/install/standalone/) or as part of docker

The intial error occurs because of the usage of compose v1 (whether it comes with docker-desktop or standalone or somewhere else).

Just install v2 and docker-compose up... will work as well

@ManuelB ManuelB linked a pull request Oct 29, 2024 that will close this issue
@cgeesink
Copy link
Contributor

@ManuelB Hello Manuel, the reason for your problems with the Compose file would be the old docker compose version 1.29.2 .

In newer Version of docker is the compose command integrated.

Are you using docker under Linux / Ubuntu? The versions provided by them is very old.

Docker provides an tutorial to integrate the official docker repository with the latest version, that should fix your problem.

Install Docker Engine on Ubuntu

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 a pull request may close this issue.

4 participants