I am a beginner.
I have 3 container up : app (laravel) , webserver (nginx) , db (mysql)
I want to work with mysql from host.
It means I want to connect from localhost\phpmyadmin to mysql in the container. But I get error 404 not found or unable to cionnect.
(for example I can connect to app from host by localhost address . But in phpmyadmin I can not ).
Why it can not find the mysql ?
You need to publish/map the port of the mysql container to the host. If you share your docker run command or docker-compose.yml, we can help you further.
Thenk you. for replying.
If you explain more, it will be great.
This is my docker-compose :
This looks ok. Maybe you’re configuring mysql to only listen to local host through
./mysql/my.cnf. What’s the content of that file?
This is the content of my.cnf
general_log = 1
general_log_file = /var/lib/mysql/general.log
and this is the result of : docker inspect db
docker_inspect_db_output.txt (10.5 KB)
I tried your setup locally with phpmyadmin running in a container and it worked for me. I’m assuming it’s on phpmyadmin’s end. You can try running it in a container. If you need it on the host look in the phpmyadmin configuration file (
config.inc.php) for the connection settings to mysql.
Here’s a working
version: "3.7" services: db: image: mysql:5.7.22 ports: - "3306:3306" environment: MYSQL_DATABASE: laravel MYSQL_ROOT_PASSWORD: 12345@6 SERVICE_TAGS: dev SERVICE_NAME: mysql volumes: - dbdata:/var/lib/mysql/ - ./my.cnf:/etc/mysql/my.cnf networks: - app-network pma: image: phpmyadmin/phpmyadmin ports: - "8080:80" networks: - app-network environment: MYSQL_ROOT_PASSWORD: 12345@6 networks: app-network: driver: bridge volumes: dbdata: driver: local
I was wrong to insist on running mysql from host .
As you say , I made a container for mysql and It work very easy and rapid.