Hello everyone, please I got this error while trying to connect my docker container that is running in an AWS EC2 instance to MYSql - “Failed to connect to MYSQL at 127.0.0.1:6666 with user root”. I did a docker ps
to show that my docker container is up and running, the result showed that my container is up.
I created my docker image using a Dockerfile and this is the content of my Dockerfile -
FROM centos
RUN cd /etc/yum.repos.d/
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
RUN yum install -y httpd
ADD index.html /var/www/html
CMD apachectl -D FOREGROUND
EXPOSE 80
MAINTAINER babatunde
ENV myenv myval
ENV myenv2 myval2
Also, the security group of my EC2 instance is set to accept request from “Anywhere”. I also did a docker inspect
on my container and the output is in the image below -
I used 127.0.0.1 as the Hostname in MYSql Workbench with port 6666 and I also tried Hostname 0.0.0.0 but both failed. I searched on this forum and found out that a similar question has been asked before https://forums.docker.com/t/failed-to-connect-to-my-sql-at-127-0-0-1-3306with-user-172-18-0-1/138077 but no solution was provided for reasons stated in that post, that’s why I’m asking this same question again. I’ve also confirmed that the Firewall on my computer isn’t blocking any port. Please does anyone knows how I can resolve this issue ? Thanks for any help in advance.