Can't connect containers mariadb and phpmyadmin - docker-compose

I get the error "mysqli::real_connect(): (HY000/2002): No such file or directory" when trying to login to phpmyadmin. I verified I can connect to the DB container from the localhost using mysql -h 127.0.0.1 -P 3306 -u root -p. Below is my docker-compose file:
version: "3.7"
########################### SECRETS
secrets:
mysql_root_password:
file: $DOCKERDIR/secrets/mysql_root_password
########################### SERVICES
services:
# Portainer - WebUI for Containers
portainer:
container_name: portainer
image: portainer/portainer-ce:latest
restart: unless-stopped
command: -H unix:///var/run/docker.sock
security_opt:
- no-new-privileges:true
ports:
- "$PORTAINER_PORT:9000"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- $DOCKERDIR/portainer/data:/data
environment:
- TZ=$TZ
# MariaDB - MySQL Database
db:
container_name: db
image: linuxserver/mariadb:latest
restart: always
security_opt:
- no-new-privileges:true
ports:
- "$MARIADB_PORT:3306"
volumes:
- $DOCKERDIR/mariadb/data:/config
environment:
- PUID=$PUID
- PGID=$PGID
- TZ=$TZ
- FILE__MYSQL_ROOT_PASSWORD=/run/secrets/mysql_root_password
secrets:
- mysql_root_password
# phpMyAdmin - Database management
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
container_name: phpmyadmin
restart: unless-stopped
depends_on:
- db
security_opt:
- no-new-privileges:true
ports:
- "$PHPMYADMIN_PORT:80"
volumes:
- $DOCKERDIR/phpmyadmin:/etc/phpmyadmin
environment:
- PMA_HOST=db
#- PMA_ARBITRARY=1
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_password
secrets:
- mysql_root_password
# Dozzle - Real-time Docker Log Viewer
dozzle:
image: amir20/dozzle:latest
container_name: dozzle
restart: unless-stopped
security_opt:
- no-new-privileges:true
ports:
- "$DOZZLE_PORT:8080"
environment:
DOZZLE_LEVEL: info
DOZZLE_TAILSIZE: 300
DOZZLE_FILTER: "status=running"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
For the life of me, I can't figure out what I am doing wrong to log into Phpmyadmin. Can someone explain my mistake or mistakes and point me in the right direction? Thanks

I figured the issue out, first was I had the network set on the pphpmyadmin section, and not db, once I added the network statement to db section, I was able to connect.

Related

SonarQube cannot access PostgresDB

I am trying to set up SonarQube self-hosted using docker with docker-compose. To use SonarQube via HTTPS I am using nginx as reverse proxy and the jrcs/letsencrypt-nginx-proxy-companion to handle the SSL-Certificate.
Now I have configured SonarQube using the following docker-compose.yml:
version: '3'
networks:
ext:
int:
volumes:
certs:
vhosts:
html:
postgresql_data:
postgresql:
sonarqube_data:
sonarqube_extensions:
sonarqube_logs:
services:
nginxproxy:
image: jwilder/nginx-proxy:alpine
container_name: nginxproxy
hostname: nginxproxy
restart:
unless-stopped
networks:
- ext
volumes:
- certs:/etc/nginx/certs:ro
- vhosts:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./config/my_proxy.conf:/etc/nginx/conf.d/myproxy.conf:ro
ports:
- 80:80
- 443:443
labels:
- com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy
environment:
- SSL_POLICY=Mozilla-Intermediate
nginxproxy_comp:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: nginxproxy_comp
hostname: nginxproxy_comp
restart:
unless-stopped
depends_on:
- nginxproxy
networks:
- ext
volumes:
- certs:/etc/nginx/certs
- vhosts:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/var/run/docker.sock:ro
sonarqube:
image: sonarqube:community
container_name: sonarqube
hostname: sonarqube
depends_on:
- db
restart:
unless-stopped
volumes:
- sonarqube_data:/opt/sonarqube/data
- sonarqube_logs:/opt/sonarqube/logs
- sonarqube_extensions:/opt/sonarqube/extensions
environment:
- SONAR_JDBC_URL=jdbc:postgresql://localhost:5432/sonarqube
- SONAR_JDBC_USER=sonarqube
- SONAR_JDBC_PASSWORD=sonarqube
networks:
- int
ports:
- 9000:9000
db:
image: postgres:12
container_name: db
hostname: db
networks:
- int
ports:
- 5432:5432
environment:
- POSTGRES_USER=sonarqube
- POSTGRES_PASSWORD=sonarqube
volumes:
- postgresql:/var/lib/postgresql
- postgresql_data:/var/lib/postgresql/data
restart:
unless-stopped
Now when I try to start docker-compose, SonarQube is giving me the following Error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader#277050dc-org.sonar.db.DefaultDatabase': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Fail to connect to database
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
Can anyone please tell me what i did wrong?
What I see here is the incorrect JDBC URL. It must below
SONARQUBE_JDBC_URL=jdbc:postgresql://db:5432/sonarqube
Since you have network between containers DB accessible via db
Also, under SonarQube container add below as well
privileged: true
Check one of my sample project in GitHub
https://github.com/shamith234/sonarqube-9.5-postgres-docker/blob/master/docker-compose.yml

Password auth failed for user "postgres"

I am trying to run my postgres server and nestjs project with docker script and it does fire up the server and database. While firing up it does run migrations too but when I open pgAdmin I see no database there and if i try to create new server i get fatal pasword incorrect error. Also my server crashes too with error saying Password authentication failed for user "postgres". It was running fine yesterday but today its not running at all. I tried pruning everything and made fresh build and then compose up but nothing. Here is docker script
version: "3.5"
services:
dev-api:
container_name: xxxxxxxx-api
build:
context: .
dockerfile: Dockerfile
depends_on:
- dev-db
environment:
DATABASE_URL: postgresql://postgres:postgres#dev-db:5432/xxxxxxx_api
APP_ENV: development
PORT: 3030
WAIT_HOSTS: dev-db:5432
ports:
- "3030:3030"
- "9229:9229"
volumes:
- .:/usr/api/
dev-db:
container_name: xxxxxxxx-postgres
image: postgres:13.5-alpine
restart: always
ports:
- "5432:5432"
volumes:
- ./pg-data:/var/lib/postgresql/data
- ./src/db/docker/init.sql:/docker-entrypoint-initdb.d/dbinit.sql
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=xxxxxxx_api
expose:
- "5432"
pgadmin:
container_name: xxxxxxx-pgadmin
image: dpage/pgadmin4:6.2
ports:
- 8080:80
volumes:
- pgadmin-data:/var/lib/pgadmin
environment:
- PGADMIN_DEFAULT_EMAIL=user#postgres.com
- PGADMIN_DEFAULT_PASSWORD=postgres
- PGADMIN_LISTEN_PORT=80
depends_on:
- dev-db
volumes:
pgadmin-data:

Mattermost Docker "/config/config.json" Permission denied

I am experimenting with mattermost docker image. I am getting Permission denied from the mattermost official docker image itself.
OS :Centos 8 Stream.
User : root - running all docker-compose commands using root.
Any other docker images(eg Wordpress) works just fine.
Any clue ?
version: "3.7"
services:
db:
container_name: mattermost-db
image: mysql:8.0.20
environment:
MYSQL_ROOT_PASSWORD: msqlroot123#
MYSQL_DATABASE: mattermost
MYSQL_USER: msqluser
MYSQL_PASSWORD: msqluser123#
command: mysqld --default-authentication-plugin=mysql_native_password
volumes:
- ./volumes/db/mysql:/var/lib/mysql
ports:
- "3306:3306"
networks:
- my-network
app:
#image: mattermost/mattermost-team-edition:release-5.33
image: mattermost/mattermost-prod-app
container_name: mattermost-docker_app_1
restart: unless-stopped
volumes:
- ./volumes/app/mattermost/config:/mattermost/config:rw
- ./volumes/app/mattermost/data:/mattermost/data:rw
- ./volumes/app/mattermost/logs:/mattermost/logs:rw
- ./volumes/app/mattermost/plugins:/mattermost/plugins:rw
- ./volumes/app/mattermost/client-plugins:/mattermost/client/plugins:rw
- /etc/localtime:/etc/localtime:ro
ports:
- "8000:8000"
environment:
- MM_USERNAME=msqluser
- DB_PORT_NUMBER=3306
- MM_DBNAME=mattermost
- DB_HOST=mattermost-db
- VIRTUAL_HOST=mattermost.abcinc.com
- VIRTUAL_PORT=8000
- LETSENCRYPT_HOST=mattermost.abcinc.com
- MM_USERNAME=mmuser
- MM_PASSWORD=mmuser_password
- edition=team
networks:
- my-network
networks:
my-network:
external:
name: my-network
The important step is described here:
https://github.com/mattermost/mattermost-docker#startingstopping-docker
chown -R 2000:2000 ./volumes/app/mattermost/
You might need to use sudo

Docker-compose postgres error: FATAL: password authentication failed for user "postgres"

I have an error with postgres in docker-compose. When I start docker-compose with docker-compose up -d, everything is right. But after 1-2 days, the error occurs. And I noticed, that when it occurs the linux machine become really slow, and I can't do any operations with docker. I tried: sudo systemctl restart docker.service to restart docker daemon, but it just stops and do nothing. But when I reboot machine, the lags disappear. I consider that something wrong with config(docker-compose.yml).
Here's my docker-compose.yml:
volumes:
common-volume:
postgres:
services:
nginx:
container_name: nginx
image: nginx:latest
ports:
- '80:80'
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
networks:
app_net:
ipv4_address: 10.5.1.5
postgres:
container_name: docker-postgres
ports:
- ${POSTGRES_PORT:-5432}:${POSTGRES_PORT:-5432}
restart: always
environment:
- POSTGRES_DB=${DB_NAME}
- POSTGRES_USER=${DB_USERNAME}
- POSTGRES_PASSWORD=${DB_PASSWORD}
- PGDATA=/var/lib/postgresql/data
image: postgres
networks:
app_net:
ipv4_address: 10.5.0.8
volumes:
- postgres:/var/lib/postgresql/data/
common:
container_name: docker-common
build: ./common
volumes:
- common-volume:/usr/src/common
auth_service:
container_name: docker-auth-service
build: ./auth-service
restart: always
environment:
- DB_HOST=postgres
- DB_USERNAME=postgres
- DB_NAME=postgres
- DB_PASSWORD=postgres
- NODE_ENV=production
- REDIS_HOST=10.5.0.7
env_file:
- .env
volumes:
- common-volume:/usr/src/common
expose:
- "8080"
depends_on:
- postgres
links:
- postgres
networks:
app_net:
ipv4_address: 10.5.0.5
redis:
container_name: redis
image: 'redis:4-alpine'
expose:
- "6379"
networks:
app_net:
ipv4_address: 10.5.0.7
networks:
app_net:
ipam:
config:
- subnet: 10.5.0.0/16
I had confronted similar issue. The problem is with this line of code for both postgresql and auth_service configuration:
restart: always
replace it with:
restart: no
or comment it out!

Access fusionAuth-app UI from outside container (external access)?

I am using the following docker-compose.yml for deployment cloned from following https://fusionauth.io/docs/v1/tech/installation-guide/docker
version: '3'
services:
db:
image: postgres:9.6
environment:
PGDATA: /var/lib/postgresql/data/pgdata
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
# Un-comment to access the db service directly
ports:
- 5432:5432
networks:
- db
restart: unless-stopped
volumes:
- db_data:/var/lib/postgresql/data
search:
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.1
environment:
- cluster.name=fusionauth
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=${ES_JAVA_OPTS}"
# Un-comment to access the search service directly
ports:
- 9200:9200
- 9300:9300
networks:
- search
restart: unless-stopped
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- es_data:/usr/share/elasticsearch/data
fusionauth:
image: fusionauth/fusionauth-app:latest
depends_on:
- db
- search
environment:
DATABASE_URL: jdbc:postgresql://db:5432/fusionauth
DATABASE_ROOT_USER: ${POSTGRES_USER}
DATABASE_ROOT_PASSWORD: ${POSTGRES_PASSWORD}
DATABASE_USER: ${DATABASE_USER}
DATABASE_PASSWORD: ${DATABASE_PASSWORD}
FUSIONAUTH_MEMORY: ${FUSIONAUTH_MEMORY}
FUSIONAUTH_SEARCH_SERVERS: http://search:9200
FUSIONAUTH_URL: http://fusionauth:9011
networks:
- db
- search
restart: unless-stopped
ports:
- 9011:9011
volumes:
- fa_config:/usr/local/fusionauth/config
networks:
db:
driver: bridge
search:
driver: bridge
volumes:
db_data:
es_data:
fa_config:
I am unable to access the fusionAuth UI screen from http://localhost:9011 or http://fusionauth:9011
How can I access the UI welcome screen from outside docker container? Is there any
enableExternal: true env variable available for docker-compose.yml?
Is there a way to test or ping the fusionAuth App server to make sure it's up and running other than using docker ps -a
This was due to an error with the docker image. An updated docker image was released hours after this question was asked, and that resolved the issue.
More details here: https://github.com/FusionAuth/fusionauth-containers/issues/47