H
H
HexUserHex2020-09-15 12:17:37
Docker
HexUserHex, 2020-09-15 12:17:37

What is wrong with this docker-compose?

There is a docker-compose in which there are two services and a database that these two services should use (although this is not the top solution BUT ..) when I try to connect to this database, I constantly get errors .. If there are people who have solid experience with docker- oh, maybe they will immediately see where I'm wrong ...5f60864b63a27716482941.jpeg

version: "3.0"

networks:
  gitea:
    external: false

services:
  
  gitea:
    image: gitea/gitea:latest
    container_name: gitea
    restart: always
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - DB_TYPE=mysql
      - DB_HOST=db:3306
      - DB_NAME=gitea
      - DB_USER=tester
      - DB_PASSWD=superpassword
    restart: always
    networks:
      - gitea
    volumes:
      - data_gitea:/data
      - timezone_gitea:/etc/timezone:ro
      - localtime_gitea:/etc/localtime:ro
    ports:
       - "3000:3000"
       - "222:22"
    depends_on:
      - db


  db:
    image: mysql:5.7
    container_name: gitea_mysql
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=testertester78
      - MYSQL_USER=admin
      - MYSQL_PASSWORD=superpassword
      - MYSQL_DATABASE=nextcloud
    networks:
      - gitea
    volumes:
      - mysql_gitea:/var/lib/mysql
    ports:
      - "3306:3306"


  adminer:
    image: adminer:latest
    container_name: adminer
    restart: always
    ports:
      - "3128:8080"
    depends_on:
      - db


  nextcloud:
    image: nextcloud:latest
    container_name: nextcloud
    restart: always
    links:
      - db
    ports:
      - "80:80"
    volumes:
      - nextcloud:/var/www/html


volumes:
  data_gitea:
  timezone_gitea:
  localtime_gitea:
  mysql_gitea:
  nextcloud:

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-09-15
@HexUserHex

immediately that the
nextcloud container and the db container caught my eye are on different networks, more precisely, in the nextcloud container, you simply did not add the network. The links construct is obsolete, use shared networks, don't forget to describe them as described by volumes and everything will be fine

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question