Hi all,
I am trying to get the docker observium container running on my Ubuntu machine. I already have the MySQL database installed and am trying to run the container like this:
docker run -d
–name observium
-p 8000:8000
-v /opt/observium/volumes/config:/config
-v /opt/observium/volumes/html:/opt/observium/html
-v /opt/observium/volumes/logs:/opt/observium/logs
-v /opt/observium/volumes/rrd:/opt/observium/rrd
yelp/observium
But then when I go to 0.0.0.0:8000 or localhost:8000 or 127.0.0.1:8000, I see the following error:
MySQL Error: Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (13)
I made sure that the mysql.sock file does exist in the /var/run/mysqld/ directory of the host machine.
And this is the section in my.cnf file which everything looks correct to me:
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
And in the same file I have:
bind-address = 127.0.0.1
Can someone please shed some light on this? Am I doing something wrong or I should be able to run the docker command above and go to the localhost:8000 URL and see something?
The container part seems to be working for you because you are able to reach observium but observium is not able to connect to MySQL DB on your host.
As you know that containers have a different filesystem from host so observium running inside container won’t see the mysql.sock which is in the host filesystem. So you should make observium connect over network to MySQL.
For the above thing to work you should bind MySQL on the ports to which the container has access. Your MySQL is listening on 127.0.0.1 which is not enough.
I hope you understood the scenario. Please let me know if you need further help.
Hi,
Thanks for your helpful reply. I understood your scenario completely but just not sure how to implement it. I have amysql installed on the host and have observium container running on the same host. Can you please let me know how exactly I can get this to work with all the details?
Thanks for your reply. I made the changes you suggested:
Inside my.cnf I added the bind-address = 0.0.0.0
Then inside the observium container I:
vi /opt/observium/config.php
And replaced the word localhost with my host’s IP address:
$config[‘db_host’] = ‘My local IP address’;
$config[‘db_user’] = ‘observium’;
But there is no place where I type the port number. And when I go to 0.0.0.0:8000 I still get an error:, it’s a different one but we’re getting close. Just liek you said we will give observium container permissions to access the database. Can you help me with that as well?
MySQL Error: Host ‘172.17.0.18’ is not allowed to connect to this MySQL server
Did I do anything wrong? Were you able to get that running on your machine? Any help would be much appreciated.
Thanks much, that worked. I had to add the user to the database and also grant access to that user. Finally got the web GUI up but now I don’t have a way to login as there is no default username and password.
There is a file called adduser.php and I supposed to be able to run it like this: “./adduser.php username password 10” and that should create the user but that fails.
Did you or anyone else have luck with this part or know how to login to the GUI?
I’ve a similar problem, when i use two container connected to a docker bridge network (mynet): one container is a tomcat one in which is deployed a war, that try to connects via hibernate to the second container, a mysql one (named "mysql-phpmyadmin, image from https://hub.docker.com/r/grzesiekb/mysql-phpmyadmin/). When, in the hibernate.cfg.xml file, i point to "localhost:3306/AT_DB) i see “connection refused”… when i point to "mysql-phpmyadmin:3306/AT_DB) i have "17-Feb-2017 08:31:25.649 SEVERE [http-apr-8080-exec-2] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [com.ATBoscoCastellano.servlets.UserSessionServlet] in context with path [/AtApplicazione1] threw exception [Servlet execution threw an e
xception] with root cause
java.sql.SQLException: null, message from server: “Host ‘tomcat8.mynet’ is not allowed to connect to this MySQL server”