Reputation: 231
I created an Ubuntu 15.10 VM on Microsoft Azure. On the Server i created a docker container with MySQL running (IP: 172.17.0.2)
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4255233555db mysql "/entrypoint.sh mysql" 16 hours ago Up 16 hours 0.0.0.0:3306->3306/tcp compose_mysql_1
I can connect over ssh to the VM and then access the MySQL-Server running in the docker container.
I now wanna have access to the MySQL-Server from the outside so that my WebApp on Microsoft Azure (same Ressource Group) can connect to the database.
I already forwarded the port 3306 of the VM to 172.17.0.2:3306.
With MySQL-Workbench from my local PC i can't connect to the MySQL-Server. In fact i am not sure which credentials i need to provide to connect. I tried it with the public ip of the VM and the root password of the MySQL-Server. But shouldn't i somewhere also provide the password and user for the VM itself?
Upvotes: 1
Views: 4946
Reputation: 7005
Other than the firewall on the actual VM, Azure manage ports security using a separate VPC Network security group. By default, the Network group associated with your VM does not allow inbound TCP connections on port 3306. You have to add that manually:
Network interfaces
Network security group
Inbound security rules
Add
and Fill as followMagic!
Upvotes: 2
Reputation: 4953
I also had troubles getting the official MySQL image running and accessible. sameersbn/docker-mysql provides an nice and easy wrapper that lets you specify user and database to be set up.
My docker-compose file has the following section:
db:
image: sameersbn/mysql:latest
volumes:
- /opt/mysql/data:/var/lib/mysql
environment:
- DB_USER=${DB_USER}
- DB_PASS=${DB_PASS}
- DB_NAME=theDatabaseName
ports:
- "3306:3306"
The details:
image
- The above mentioned wrapper.volumes
- Mapping the data on the persistent host.environment
- Variables that define the database setup. Either give plain text as with DB_NAME
or access environment variables through the ${...}
syntax.ports
- Map out the port 3306 on the host so it may be accessed remotely.Upvotes: 0