I need an easy way to create an environment with PHP, NGINX, MySQL, and phpmyadmin using Docker-compose.
I have successfully created a PHP environment using NGINX.
Now I want to add a database with MySQL and phpmyadmin. These two components don't seem to work. For example, I cannot access phpmyadmin by specifying port "8081". I access the local server using the local IP address and the port at the end of the address.
When I want to call phpmyadmin, the browser window tells me "Unable to connect to server".
This is the docker-compose.yml file:
version: "3.9" services: web: image: nginx:latest ports: - "8080:80" volumes: - ./src:/var/www/html - ./default.conf:/etc/nginx/conf.d/default.conf links: -php-fpm php-fpm: image: php:8-fpm volumes: - ./src:/var/www/html mysql: image:mysql container_name: mysql environment: MYSQL_ROOT_PASSWORD: '' MYSQL_DATABASE:baton MYSQL_USER:baton MYSQL_PASSWORD: ' ' ports: - "3306:3306" volumes: - ./database/mysql:/var/lib/mysql phpmyadmin: image: phpmyadmin/phpmyadmin container_name: pma links: - mysql environment: PMA_HOST: mysql PMA_PORT: 3306 PMA_ARBITRARY: 1 restart: always ports: - 8081:80
Hope everyone can help!
Now I found that I made a mistake when connecting to the database through phpmyadmin. I got the second database and it's already running on port 3306. I have now switched to the existing database and the connection now works!