Links of the Docker-Compose - Laravel + Redis

Asked

Viewed 296 times

-1

I am creating a development environment for a Docker-based 5.0 Standard project.

I managed a file docker-compose.yml for http://phpdocker.io and I made some modifications, he’s this way:

###############################################################################
#                          Generated on phpdocker.io                          #
###############################################################################
version: "3.1"
services:
  webserver:
    image: nginx:alpine
    container_name: rdias-app-webserver
    working_dir: /application
    volumes:
      - .:/application
      - ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
    ports:
      - "8080:80"
    links:
      - redis

  php-fpm:
    build: phpdocker/php-fpm
    container_name: rdias-app-php-fpm
    working_dir: /application
    volumes:
      - .:/application
      - ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/7.0/fpm/conf.d/99-overrides.ini
    links:
      - redis

  redis:
    image: redis:alpine
    container_name: rdias-app-redis
    command: redis-server --requirepass Redis2019!
    ports:
      - "6379:6379"
    volumes:
      - ./redis:/data

The application is working properly but it does not connect in any way in redis.

Host machine can connect smoothly.

I don’t know if I link the right way. I’m not used to Docker.

  • No links, pass container name, ex: redis:rdias-app-redis

1 answer

0


I managed to solve the problem in a simple way. Just passing as the redis host, the string redis referring to the service name on the Docker.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.