Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can we access PHPMyAdmin? #4

Closed
aaravrana opened this issue Nov 7, 2019 · 1 comment
Closed

How can we access PHPMyAdmin? #4

aaravrana opened this issue Nov 7, 2019 · 1 comment

Comments

@aaravrana
Copy link

How can we access phpmyadmin using browser to access the database? Can we add it to the docker image itself?

Thanks,
aR

@erpushpinderrana
Copy link
Owner

Yes, there are two ways of doing this. Either install it on existing docker images repo or download it along with other docker images.

Manually Download
To download the phpmyadmin image, simply run below command and link it to your MySql container. More info - https://docs.phpmyadmin.net/en/latest/setup.html#installing-using-docker

docker pull phpmyadmin/phpmyadmin

Using docker-compose
In order to install with rest of docker images, you may include the below code in your docker-compose.yml file as shown below:

phpmyadmin:
    image: phpmyadmin/phpmyadmin
    ports:
      - 8080:80
    links:
      - mysql:mysql
    environment:
      PMA_HOST: mysql
      MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD}"
      MYSQL_USER: "${DB_USERNAME}"
      MYSQL_PASSWORD: "${DB_PASSWORD}"
    restart: always
    networks:
      - backend

Please note I don't want to add many services to my existing branch because I want to keep it lightweight. After adding the above code, your docker-compose.yml file should be:

version: "3.2"
services:
  php:
    build: 
      context: './php/'
      args:
       PHP_VERSION: ${PHP_VERSION}
    networks:
      - backend
    volumes:
      - ${PROJECT_ROOT}/:/var/www/html/
    container_name: php
  apache:
    build:
      context: './apache/'
      args:
       APACHE_VERSION: ${APACHE_VERSION}
    depends_on:
      - php
      - mysql
    networks:
      - frontend
      - backend
    ports:
      - "80:80"
    volumes:
      - ${PROJECT_ROOT}/:/var/www/html/
    container_name: apache
  mysql:
    image: mysql:${MYSQL_VERSION:-latest}
    restart: always
    ports:
      - "3306:3306"
    volumes:
            - data:/var/lib/mysql
    networks:
      - backend
    environment:
      MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD}"
      MYSQL_DATABASE: "${DB_NAME}"
      MYSQL_USER: "${DB_USERNAME}"
      MYSQL_PASSWORD: "${DB_PASSWORD}"
    container_name: mysql

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    ports:
      - 8080:80
    links:
      - mysql:mysql
    environment:
      PMA_HOST: mysql
      MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD}"
      MYSQL_USER: "${DB_USERNAME}"
      MYSQL_PASSWORD: "${DB_PASSWORD}"
    restart: always
    networks:
      - backend

networks:
  frontend:
  backend:
volumes:
    data:

Now you need to rebuild the images again and you will be able to access phpmyadmin on your localhost using http://localhost:8080/ URL.

Hope it helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants