To get faster answers, maybe you should put a bit of efforts into explaining your problem. Like, you know, formatting and such
Now, for what I understand, you just want to change the name of your container. In docker-compose, you can do this by setting the “container_name” property on any of your containers.
For example:
db:
image: mysql:5.7
container_name: db
If you don’t want to change the container name, but needs ‘user-friendly’ names for discovery, you can as well set the ‘hostname’ property, or you can add network aliases, like such:
P.S: Feel free to consult docker-compose documentation for information, it will save you 6 months sitting on your hands instead of a simple… google search ^^
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.dynamodb-local.networks.default contains "ALIAS_NAME", which is an invalid type, it should be an array
be sure to add a hyphen when writing your alias in docker compose. Using the same example as above:
Thanks for reporting back! Without reading any documentation, the plural form of aliases may already reveal it’s a list, a.k.a. an array. If you need any help on YAML, see, e.g.:
Replace myservice with the name of your service and custom-container-name with your preferred container name.
Save the changes to your docker-compose.yml file.
When you bring up your Docker Compose environment using docker-compose up, the container associated with the service will have the custom name specified in the container_name field.
Keep in mind that container names must be unique within your Docker environment. If you have multiple instances of the same service, you may need to use some form of dynamic naming or include additional identifiers to ensure uniqueness.To get comprehensive guide check out this article Custom Container Names In Docker Compose
How can I make a mix of default container name with a custom postfix?
I like that if I drop container_name then it’s auto-generated as [project]-[service]-[index] because I can change “name” of my project and it will be propagated to the container name. But in one case I’d like to have my custom postfix in container name with version of DB engine and don’t loose the autonaming feature. So I’d like to have something like this: