coollabsio / coolify

An open-source & self-hostable Heroku / Netlify / Vercel alternative.
https://coolify.io
Apache License 2.0
31.53k stars 1.61k forks source link

[Bug]: COOLIFY_CONTAINER_NAME does not match any of container names #3280

Open fipnooone opened 2 weeks ago

fipnooone commented 2 weeks ago

Description

Created containers:

coolify-containers

Docker inspect for node service show this env:

"Env": [
               // other
                "COOLIFY_CONTAINER_NAME=lck0o48-061119181951",
                // other
            ],

Docker inspect for mysql service:

"Env": [
               // other
                "COOLIFY_CONTAINER_NAME=lck0o48-061119181951",
                // other
            ],

Shouldn’t all containers have the same identifier? That is, 061119181951 in this case.

Minimal Reproduction (if possible, example repository)

docker-compose file:

services:
  staging-project-nginx:
    image: nginx:alpine
    container_name: staging-project-nginx
    depends_on:
      - staging-project-node
    ports:
      - '8001:80'
    volumes:
      - './:/var/app'
      - './deploy/nginx/staging:/etc/nginx/conf.d/'
    networks:
      - staging-project-network
  staging-project-node:
    container_name: staging-project-node
    depends_on:
      - staging-project-mysql
    build:
      context: .
      dockerfile: Dockerfile
    restart: always
    environment:
      - NODE_ENV=production
    ports:
      - '${DEPLOYMENT_PROXY_PORT:-3201}:3000'
    working_dir: /app
    networks:
      - staging-project-network
    command: pnpm run prisma:migrate:deploy
  staging-project-mysql:
    image: mysql:8.4
    container_name: staging-project-mysql
    environment:
      MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
      MYSQL_ROOT_HOST: '%'
      MYSQL_DATABASE: '${DB_DATABASE}'
      MYSQL_USER: '${DB_USERNAME}'
      MYSQL_PASSWORD: '${DB_PASSWORD}'
    ports:
      - '3306:3306'
    volumes:
      - 'staging-project-mysql:/var/lib/mysql'
    networks:
      - staging-project-network

networks:
  staging-project-network:
    name: staging-project-network
    internal: true
    driver: bridge
volumes:
  staging-project-mysql:
    driver: local

Part of my env file:

DB_DATABASE=databasename
DB_USERNAME=user
DB_PASSWORD=password
MYSQL_ROOT_PASSWORD=password
DB_HOST=staging-project-mysql-${COOLIFY_CONTAINER_NAME}
DATABASE_URL=mysql://root:${MYSQL_ROOT_PASSWORD}@${DB_HOST}:3306/${DB_DATABASE}

Exception or Error

Screenshot 2024-09-01 at 13 54 51

Version

v4.0.0-beta.323

Cloud?

djsisson commented 1 week ago

they are in the same network so you can use the container name of staging-project-mysql

fipnooone commented 5 days ago

they are in the same network so you can use the container name of staging-project-mysql

That's what i'm trying to do. When coolify starts an app, it generates unique container names, so i can't use the names from the original docker-compose.

djsisson commented 5 days ago

@fipnooone you can use the service name, this doesn't change

fipnooone commented 3 days ago

@fipnooone you can use the service name, this doesn't change

🤦 thank you. But i'll keep this issue open, since COOLIFY_CONTAINER_NAME doesn't work as it should. Or maybe am i wrong here too?

djsisson commented 3 days ago

@fipnooone thats the container name of the app, not the database, jsut use staging-project-mysql