Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

312
Visualizações
Unable to connect to dockerized mysql db remotely

On my AWS ec2 server I have docker 1.9.1 installed. In an image test_image based from ubuntu:trusty official docker image, I have tried to setup the LEMP(Linux, Nginx, MySQL, PHP) architecture.

Following is the docker command i have used to start my container:

docker run --name test_1 -d -p 80:80 -p 3306:3306 test_image /bin/sh -c "while true; do echo daemonized docker container; sleep 5000; done"

I have exposed port 80 and 3306 to the host's network interface and have also allowed AWS's security group to allow inbound connections to these ports. Connection type in security group is: MYSQL/Aurora and protocol is: TCP (I know its not very secure, its only for initial implementation. Production setup will be different)

I followed this DigitalOcean tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04

After installing Nginx and starting it I am able to test it in the browser via ec2's pubic ip i.e. http://xxx.xxx.xxx.xxx shows the default nginx welcome page.

While installing MySQL, I followed the following commands in the docker container:

apt-get install mysql-server
mysql_install_db
/etc/init.d/mysql start
mysql_secure_installation

I have given a password to my root user and during mysql_secure_installation i had allowed remote access to root user.

mysql -u root -p command from inside the container connects me to the mysql db but not from outside the container.

Also from my local machine: I tried with mysql-client: mysql -h xxx.xxx.xxx.xxx -u root -p

I got the following error: ERROR 2003 (HY000): Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (111)

and also through mysql workbench but I still can't connect to the mysql db.

What am I doing wrong?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

In your host mysql's my.cnf set the bind address to 0.0.0.0 so that mysql listens on all network interfaces

bind-address = 0.0.0.0

The default config is:

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address   = 127.0.0.1
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda