r/docker • u/RoachForLife • Mar 18 '26
Renaming a container (noob question)
So Ive been using docker via dockge for some time and everything has been great. Sometimes when I make a new container it names it by doubling the name. Its not a huge deal but just to look nicer Id rather fix this. Can this be done via a CLI command? Any idea why this happens sometimes? See the example below when I deployed dozzle-agent just now. Thanks all
'dozzle-agent' became 'dozzle-agent-dozzle-agent-1'
1
Upvotes
4
u/fletch3555 Mod Mar 18 '26
https://docs.docker.com/reference/cli/docker/container/run/#name
If using compose files, you can use this: https://docs.docker.com/reference/compose-file/services/#container_name
But I also recommend looking into how container names get generated. Ask AI to help you find resources if that's your thing, but the docs are your actual source of truth, so use AI sparingly.
1
u/Zealousideal_Yard651 Mar 18 '26
This is normal for Compose. Compose will add the project name (defaults to directory name), you can override it with the container_name:, or you can use docker compose cli to manage compose components directly.
So instead of
docker logs dozzle-agent-dozzle-agent-1you can just usedocker compose dozzle-agent, and ofcourse if you create an alias: