I have tested different things like psql container ip, 127.0.0.1, different docker-compose.yml configurations from sites where solutions are suggested, but none works. :( docker-compose.yml -
services:
web:
build: .
ports:
- "4200:4200"
stdin_open: true
tty: true
environment:
- DATABASE_URL=postgresql://postgres:12345@db/vex
depends_on:
- database
database:
image: postgres
container_name: database
restart: unless-stopped
environment:
POSTGRES_PASSWORD: 12345
POSTGRES_DB: axle
volumes:
- ./postgres-data:/var/lib/postgresql/data
ports:
- '5432:5432'
apache:
image: "httpd:latest"
volumes:
- ./httpd.conf:/etc/httpd/conf
volumes:
db:
driver: local
Dockerfile -
RUN apt-get update && apt-get upgrade -y && apt-get install -y curl && apt-get install -y git && apt-get install -y libpq-dev && docker-php-ext-install pdo pdo_pgsql
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
COPY /vex /var/www/html/vex
COPY /ember-cli-inject-live-reload /var/www/html/vex/frontend/node_modules
WORKDIR "/var/www/html/vex/backend"
RUN composer install -n
RUN php artisan session:table
RUN php artisan queue:table
RUN php artisan migrate
laravel db config -
'host' => 'database',
'database' => 'vex',
'username' => 'postgres',
'password' => '12345',
'charset' => 'utf8',
'port' => '5432'
And I am getting this error - SQLSTATE[08006] [7] could not translate host name "database" to address: Name or service not known