I'm trying to connect a PHPMyAdmin-Container to a MySQL-Container to view the databases.
I have started the MySQL container via
$ docker run --name databaseContainer -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql
$ docker run --name myadmin -d --link databaseContainer:mysql -p 8080:8080 phpmyadmin/phpmyadmin
Instead of starting them one by one, use docker compose.
Create a docker-compose.yml file
version: '2' services: db: image: mysql environment: MYSQL_ROOT_PASSWORD:my-secret-pw ports: # just if you also want to access it directly from you host # node neede for phpmyadmin - "3306:3306" phpmyadmin: image: phpmyadmin/phpmyadmin depends_on: - db ports: - "8080:8080"
Then start it using
docker-compose up in the same folder your
docker-compose.yml file is located.
When phpmyadmin opens, type 'db' as the hostname, since that is the name of the service. All the links are setup for you and it will work out of the box.
Thats much sipler - docker run overcomplicates things and is not practical for those things - never.
Hint: if docker-compose is not installed for you, install it using this official howto https://docs.docker.com/compose/install/