hiromaily / go-gin-wrapper

go-gin web framework sample
MIT License
23 stars 9 forks source link

(Question) How to write docker-compose file for a similar backend. #5

Open Mikhail14all opened 3 years ago

Mikhail14all commented 3 years ago

I am struggling with writing docker-compose file with 2 databases. I just saw your docker-compose file here https://github.com/hiromaily/go-gin-wrapper/blob/master/docker-compose.yml
but I don't understand what you have written in the volumes part in mysql service.
Can you please help or provide link to some tutorial for a similar backend because I am struggling with a problem to unable to connect my container to the databases using docker-compose.

hiromaily commented 3 years ago

Top level of volumes db is used for /var/lib/mysql directory in mysql container to store data permanently into volume.

volumes:
  db: {}
services:
  # MySQL
  mysql:
    #env_file: .env
    image: mysql:5.7
    container_name: web-mysql
    ports:
      - "3306"
    volumes:
      - db:/var/lib/mysql

read these documents https://docs.docker.com/compose/compose-file/#volumes-for-services-swarms-and-stack-files https://docs.docker.com/storage/volumes/