Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

241
Visualizações
Docker compose not prepending project name to the container names when running multiple instances

I have a set of docker that I run using docker-compose up -d pretty basic so far

I want to run multiple instances of my project and I have read this Run multiple docker compose

Now when running docker-compose up -p PRNAME -d compose is not prepending project name to containers like prname_container1 and I'm getting the following error :

ERROR: for container1  Cannot create container for service service1: Conflict. The container name "/container1" is already in use by container "f7aeb2ef782556ae5b0". You have to remove (or rename) that container to be able to reuse that name.

I might be missing something out here.

A part of my docker-compose.yml looks like

services:
  service1:
    image: "${PROJECT_REPO}:image"
    container_name: "container1"
    ports:
      - 443:443
      - 8000:80
    networks:
      - db
      - proxy
      - oauth
    depends_on:
      - db
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

When you explicitly set container_name: in your docker-compose.yml file, the container name will be exactly what you specify; Docker Compose won't add its per-directory prefix to it.

Usually this doesn't matter to you at all, and it's safe to remove container_name:. You will still be able to reach other containers using their service name in docker-compose.yml as hostnames, and the docker-compose CLI provides wrappers for management commands like docker-compose stop that will act on the correct container.

You will also hit trouble with ports: and there is less of a clear solution here. Only one container or process can bind to a specific port on the host. You can leave off the first port number in ports:, and Docker will pick a port for you

ports:
  - '80'
  - '443'

but then you need to manually look up the corresponding host port number

docker-compose port service1 80
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda