Skip to content

"Bern": Docker web container can't connect to db container. fails to recognise working solution #62

@joshuamkite

Description

@joshuamkite
docker network create wordpress_net
docker network connect wordpress_net wordpress
docker network connect wordpress_net mariadb
5d9697c2a030a4469c2dedbe8be0541d4022a6545c036fa42a335be319dc05bf
root@ip-172-31-19-232:~# docker exec wordpress mysqladmin -h mariadb -u root -ppassword ping
mysqld is alive
root@ip-172-31-19-232:~# exit
admin@ip-172-31-19-232:/$ cat ~/agent/check.sh
#!/usr/bin/bash
res=$(sudo docker exec wordpress mysqladmin -h mysql -u root -ppassword --connect-timeout 2 ping)
res=$(echo $res|tr -d '\r')

if [[ "$res" = "mysqld is alive" ]]
then
  echo -n "OK"
else
  echo -n "NO"
fi

admin@ip-172-31-19-232:/$ ~/agent/check.sh
mysqladmin: connect to server at 'mysql' failed
error: 'Unknown MySQL server host 'mysql' (-2)'
Check that mysqld is running on mysql and that the port is 3306.
You can check this by doing 'telnet mysql 3306'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions