-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Project name in docker-compose.yml #1123
Comments
It is definitely a duplicate of #45 |
Like @igor-lemon wrote in #45 (comment):
You can find more options here: https://docs.docker.com/compose/env-file/ |
Dawg this is such a basic feature |
Would it be so difficult to add the possibility of setting the project name directly from inside the docker-compose.yml file ? |
Not really helpful if you have several YAML files in the same directory that you wanna use different project names for. Can't believe this function doesn't exist. version: '3.8'
project_name: foo
services:
... would be so nice |
…tly does not result in creation of a separate deployment, see also <docker/compose#1123 (comment)>
Any updates? |
@f1ames0ff the support was introduce in compose-go v1.1.0 so it supported in Compose v2 since version |
Cannot find the information, could you be more explicit about "the support"? Thank you! |
version: "3"
name: "my-project" # <--- this
services:
mysql: ... |
Is
|
@nemanjam It's working for me - I'm using Docker compose v2 which I believe is required. If you have docker desktop, you can go to settings and flip on v2 support. |
I use v3.8 and I had to do it like this |
I believe you must use the newer |
@MatthewLymer ** commented 16 days ago:
Umm, no:
|
@aaroncrawford commented 16 days ago:
Can you show an example? I use CLI only, and setting |
When I just set I dropped |
OK, so now I get the idea. There are two seemingly related things that can have the second version:
The latter works as a Docker plugin, not as a standalone binary like V1. So, my summary is that you probably need to install Docker Compose V2 according to your setup: ... and maybe then the |
@boxertech commented 2 hours ago:
Hey, what's the exact v2 version number of your Compose? |
Documented here: Implementation: |
That first link is "broken" - I believe it should now be https://docs.docker.com/compose/compose-file/04-version-and-name/ |
From what version of Docker Compose is this field available? I am running
|
Ah, indeed, cheers. |
I have a number of projects which are using docker-compose and I'm starting to have the need to specify the project name directly into the
docker-compose.yml
Consider this scenario:
I have two projects with the following directory structures
And with two
docker-compose.yml
like this:When I issue a
docker-compose up
in theproject1
directory it will start three containers with the following namesdocker_web_1
,docker_fpm_1
,docker_redis_1
.If now I issue the same command in the
project2
directory it recreates the same containers of project1 instead creating it's own.I know that I can change the project name using the
-p
option or theCOMPOSE_PROJECT_NAME
environment variable but IMHO would be useful to have in thedocker-compose.yml
something likeproject_name: project1
.My docker-compose.yml would become:
The text was updated successfully, but these errors were encountered: