0

I want to spawn MySQL & PHPMyAdmin docker containers. Mysql container can be accessed via 3306 port & PHPMyAdmin can be accessed through 8280 port.

My question is, how a PHP application can be configured to access the MySQL docker container on 3306 port and the PHPMyAdmin can be configured for MySQL.

Thanks.

3
  • I have been gone through hub.docker.com/_/mysql but it did not help me in this case. Commented Oct 29, 2019 at 4:23
  • Probably best way is to create a docker-compose file that includes both images. However, you need to connect them to the same network. More info can be found here Commented Oct 29, 2019 at 4:57
  • Thanks @FarzadVertigo Commented Oct 30, 2019 at 2:09

3 Answers 3

1

Start MySQL server

docker run --name mysql -e MYSQL_ROOT_PASSWORD=password -d mysql 

Start phpAdmin with link to mysql container

docker run --name myadmin -d --link mysql:db -p 8080:80 phpmyadmin/phpmyadmin 

PHPAdmin application will be serving on localhost:80. MySQL credentials will be root/password.

We can now use docker-compose for this solution which is more portable.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use the offical image for MySQL and PHPMyAdmin.

version: '3.1' services: db: image: mysql command: --default-authentication-plugin=mysql_native_password environment: MYSQL_ROOT_PASSWORD: example phpmyadmin: image: phpmyadmin/phpmyadmin ports: - 8081:80 

To access it from php container, just add your php container in the docker-compose, so the connection string should be like

host:db user: root pass: example 

Comments

0

You can use Adminer a database management tool.

You need the below configuration in docker-compose.yml for Mysql and adminer.

 mysqldb: container_name: mysqldb image: mysql restart: always environment: - MYSQL_USER= 'xyz' - MYSQL_PASSWORD='pwd0123456789' - MYSQL_DB= 'testdb' networks: - main adminer: container_name: adminer image: adminer restart: always ports: - 4041:8080 networks: - main-network depends_on: - mysqldb 

1 Comment

To access adminer use the following configuration as per the above docker-compose.yml file. URL : domain:4041 "system:"MySQL', "Server":"mysqldb","username":"xyz", "password":"pwd0123456789', "Database":"testdb"

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.