Hi!
If I run the metabase docker image in bridge mode + port biding, it works. But I need to make it run
in "host" mode.
When my compose is up, it connects to mysql, but I can't connect to the http 3000 port.
I tried to use MB_JETTY_HOST=0.0.0.0, but in the image, metabase is listening only the IPv6 :::3000, not the IPv4.
Can anyone help me?
Thank you
version: "3.9"
services:
metabase:
image: metabase/metabase
container_name: metabase
restart: unless-stopped
network_mode: host
environment:
- JAVA_TIMEZONE=America/Sao_Paulo
- MB_JETTY_HOST=0.0.0.0
- MB_DB_TYPE=mysql
- MB_DB_DBNAME=metabase
- MB_DB_PORT=3306
- MB_DB_USER=metabase
- MB_DB_PASS=******
- MB_DB_HOST=localhost
Yeh. I tried. Port mapping doesn't work with host networking. I'm having to redesign my server because of this.
All others servers (MySQL, MongoDB, Dotnet core, etc..) Working perfectly with networking host (aws ec2 Amazon Linux 2). Just metabase isn't.
@mcardia And can you supply examples of how you're doing it with MySQL?
Yes, I can. But there is nothing wrong about what is working...
Only metabase is "complaining" about it.
version: "3.9"
services:
mysql:
image: mysql:5.7
container_name: mysql
command: --default-authentication-plugin=mysql_native_password
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ****
volumes:
- mysql-data:/var/lib/mysql
network_mode: host
volumes:
mysql-data:
@mcardia Are you actually running a swarm or why are you using version 3.9? Also, which version of Docker are you using?
I cannot reproduce locally - it's working fine, and I'm seeing MySQL listening on IPv6 too.
lsof: no pwd entry for UID 999
mysqld 400075 999 21u IPv6 9955886 0t0 TCP *:3306 (LISTEN)
lsof: no pwd entry for UID 999
mysqld 400075 999 40u IPv6 9957919 0t0 TCP localhost:3306->localhost:59522 (ESTABLISHED)
lsof: no pwd entry for UID 2000
java 400338 2000 11u IPv6 9958401 0t0 TCP *:3000 (LISTEN)
lsof: no pwd entry for UID 2000
java 400338 2000 22u IPv6 9958416 0t0 TCP localhost:59522->localhost:3306 (ESTABLISHED)
Here's the two yaml files I'm testing with:
version: "3.7"
services:
mysql:
image: mysql:5.7
container_name: delete-mysql
command: --default-authentication-plugin=mysql_native_password
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: dbmetabaserootpassword
MYSQL_DATABASE: metabase
MYSQL_USER: metabase
MYSQL_PASSWORD: metabasedatabasepassword
network_mode: host
version: "3.7"
services:
metabase:
image: metabase/metabase
container_name: delete-metabase
restart: unless-stopped
network_mode: host
environment:
- JAVA_TIMEZONE=America/Sao_Paulo
- MB_JETTY_HOST=0.0.0.0
- MB_DB_TYPE=mysql
- MB_DB_DBNAME=metabase
- MB_DB_PORT=3306
- MB_DB_USER=metabase
- MB_DB_PASS=metabasedatabasepassword
- MB_DB_HOST=localhost
And validation: curl -v http://localhost:3000
* Trying 127.0.0.1:3000...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET / HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Mon, 24 May 2021 20:47:43 GMT
< X-Frame-Options: DENY
< X-XSS-Protection: 1; mode=block
< Last-Modified: Mon, 24 May 2021 17:47:43 -0300
< Strict-Transport-Security: max-age=31536000
< Set-Cookie: metabase.DEVICE=0f993bd6-dc44-4628-9b24-e6ec6be521ec;HttpOnly;Path=/;SameSite=Lax;Expires=Fri, 24 May 2041 17:41:48 -0300
< X-Permitted-Cross-Domain-Policies: none
< Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate
< X-Content-Type-Options: nosniff
< Content-Security-Policy: default-src 'none'; script-src 'self' 'unsafe-eval' https://maps.google.com https://apis.google.com https://www.google-analytics.com https://*.googleapis.com *.gstatic.com 'sha256-lMAh4yjVuDkQ9NqkK4H+YHUga+anpFs5JAuj/uZh0Rs=' 'sha256-sMNbXyc1lLzhHbH/CKs11HIQMnMkZAN2eA99WhJeEC0=' 'sha256-JJa56hyDfUbgNfq+0nq6Qs866JKgZ/+qCq2pkDJED8k='; child-src 'self' https://accounts.google.com; style-src 'self' 'unsafe-inline'; font-src 'self' ; img-src * 'self' data:; connect-src 'self' metabase.us10.list-manage.com ; manifest-src 'self'; frame-ancestors 'none';
< Content-Type: text/html;charset=utf-8
< Expires: Tue, 03 Jul 2001 06:00:00 GMT
< Transfer-Encoding: chunked
< Server: Jetty(9.4.32.v20200930)
<
...
<title>Metabase</title>
...
And my /etc/hosts
is very basic (I don't have IPv6 usage in my network):
127.0.0.1 localhost
::1 ip6-localhost ip6-loopback
I didn't know I couldn't use version 3.9... I always use the latest. My docker Engine is 20.10.6 (Desktop 3.3.3)
Now it's working (in bridge mode). I managed to organize/redesign my environment using 3 docker networks (It's better now, I should have done this earlier). But the mystery remains.
Thank you.
@mcardia Version 2 is for docker-compose - version 3 is for swarm stacks:
https://forums.docker.com/t/option-network-mode-host-in-docker-compose-file-not-working-as-expected/51682/8
https://docs.docker.com/compose/compose-file/compose-versioning/#version-3
I cannot reproduce on 20.10.2, so either it's something to do with version changes or something else specific to your environment.
But great that you got it working.
I'm running into this issue as well. I can't connect to my local sql server instance.
docker run -d --net=host -v /metabase/metabase-data:/metabase-data -e "MB_JETTY_HOST=0.0.0.0" -e "MB_DB_FILE=/metabase-data/metabase.db" --name metabase metabase/metabase
Doesn't appear to be binding the port correctly?
SQL Server in docker with the same --net=host
is binding ports correctly
Any update on this? Am I the only one not able to get metabase to bind to host?
@aarthur If you need Metabase to connect to something on the host, then you don't need to place Metabase on the host, but you simply reference the host in the connection setup, when setting up the database in Metabase:
https://stackoverflow.com/questions/28056522/access-host-database-from-a-docker-container
As I already wrote earlier, I cannot reproduce and I provided a lot of information.
I was able to resolve this by using dockers internal host name to test with my locally running DB.
host.docker.internal