adhocore / docker-lemp

A single container LEMP complete fullstack with latest release of PHP8.0.30/8.1.29/8.2.23/8.3.11, MySQL, nginx, PostgreSQL, mailcatcher, beanstalkd, elasticsearch, memcached, redis, adminer and all you ever need; on top alpine3.17+ for both arm and amd arch
https://hub.docker.com/r/adhocore/lemp
MIT License
153 stars 40 forks source link

Docker compose setup #14

Closed Kabingeran closed 4 years ago

Kabingeran commented 4 years ago

Hi! I get errors like: [08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up. [HY000][1130] null, message from server: "Host '172.18.0.1' is not allowed to connect to this MariaDB server". [Warning] Aborted connection 10 to db: 'unconnected' user: 'unauthenticated' host: '172.18.0.1' (This connection closed normally without authentication)

How to configure docker compose file ?

adhocore commented 4 years ago

hmm the mysql (or mariadb here) inside the docker is not meant to be used from host context. but the dockerized app itself can access database at 127.0.0.1:3306 as said in docs.

if you still want db access from host context you can expose the port in docker-compose.yaml:

# ./docker-compose.yml
version: '3'

services:
  app:
    image: adhocore/lemp:7.4
    container_name: some-app
    volumes:
      - db_data:/var/lib/mysql
    ports:
      - 8080:80
      - 13306:3306 # <------ this
    environment:
      MYSQL_ROOT_PASSWORD: supersecurepwd
      MYSQL_DATABASE: appdb
      MYSQL_USER: dbusr
      MYSQL_PASSWORD: securepwd

volumes:
  db_data: {}

then access db at 127.0.0.1:13306 from host context.

Kabingeran commented 4 years ago

It did not help I just connect to MySQL from the IDE. It would also be great to configure ssh

adhocore commented 4 years ago

IDE is in host so port expose and usage with 127.0.0.1:13306 is the way to go.

another way could be terminal access: docker exec -it yourcontainername mysql -uyouruser -p

Kabingeran commented 4 years ago

After restarting OS - it worked!

adhocore commented 4 years ago

ok then closing

Kabingeran commented 4 years ago

Continuing, I would like to ask you to specify other ports by analogy.