Can't start pgadmin container on linux server - linux

I'm trying to migrate project from mysql to postgres using docker and docker compose file.
I'm connected to Linux server remotely .
My docker compose file :
version: '3.7'
services:
database:
container_name: ${PROJECT_NAME}-database
image: postgres:12
restart: unless-stopped
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: admin
POSTGRES_DB: dbtest
ports:
- "${POSTGRES_PORT}:5432"
volumes:
- ./docker/postgres/local_pgdata:/var/lib/postgresql/data
pgadmin:
image: dpage/pgadmin4
depends_on:
- database
container_name: ${PROJECT_NAME}-pgadmin4
restart: unless-stopped
ports:
- "${PGADMIN_PORT}:5454"
environment:
PGADMIN_DEFAULT_EMAIL: khaled.boussoffara-prestataire#labanquepostale.fr
PGADMIN_DEFAULT_PASSWORD: admin
PGADMIN_LISTEN_PORT: 5454
volumes:
- ./docker/pgadmin/pgadmin-data:/var/lib/pgadmin
My env file :
PROJECT_NAME=iig
PROJECT_FOLDER_NAME=sf_iig_api
HTTP_PORT=12078
HTTPS_PORT=12077
POSTGRES_PORT=12076
PGADMIN_PORT=5050
docker-compose ps :
I can't start pgadmin :

Your compose file seems okay to me, I use different ports, but my set-up is quite close to yours.
The error message recommends "check the proxy and firewall" (vérifer le proxy et le pare-feu) ... did you check it? I would use netcat:
nc -v -z RemoteHost Port
At least this could result in a helpful error message.

Related

Docker postgres connection refused when trying to pg_restore

Internal connection between my Spring Boot app and postgres db works fine but when I want to connect to db through init_database.sh and pg_restore I get pg_restore: error: connection to server at "db" (192.168.224.2), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections?. In this .sh script I use the same host and port as in application.properties (where connection works fine as I said before).
I simply want to do a pg_restore from init_database.sh in my Docker container.
docker-compose.yml
services:
db:
container_name: db
hostname: db
image: postgres:14-alpine
command: -c 'max_connections=250'
ports:
- "5430:5432"
environment:
POSTGRES_DB: endlessblow_db
POSTGRES_USER: kuba
POSTGRES_PASSWORD: pass
volumes:
- ./init.dump:/init.dump
- ./init_database.sh:/docker-entrypoint-initdb.d/init_database.sh
restart: always
app:
container_name: app
image: 'endlessblow-server:latest'
build: ./
ports:
- "8000:8080"
depends_on:
- db
init_database.sh
#!/bin/sh
pg_restore --no-privileges --no-owner -h db -p 5432 -U kuba -d endlessblow_db init.dump
application.properties
spring.datasource.jdbc-url=jdbc:postgresql://db:5432/endlessblow_db
spring.datasource.url=jdbc:postgresql://db:5432/endlessblow_db
spring.datasource.username=kuba
spring.datasource.password=pass
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.platform=postgres
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
How to solve that? Thank you!
in config of service "app", try following:
app:
...
depends_on:
- db
links:
- db
without links, docker network will isolate containers without explicitly exposing them to one another.

Docker Cassandra Access in Client Running Under Same Docker

My docker-compose file as below,
cassandra-db:
container_name: cassandra-db
image: cassandra:4.0-beta1
ports:
- "9042:9042"
restart: on-failure
volumes:
- ./out/cassandra_data:/var/lib/cassandra
environment:
- CASSANDRA_CLUSTER_NAME='cassandra-cluster'
- CASSANDRA_NUM_TOKENS=256
- CASSANDRA_RPC_ADDRESS=0.0.0.0
networks:
- my-network
client-service:
container_name: client-service
image: client-service
environment:
- SPRING_PROFILES_ACTIVE=dev
ports:
- 8087:8087
links:
- cassandra-db
networks:
- my-network
networks:
my-network:
I use Datastax Java driver to connect cassandra in client service, which also runs inside docker.
CqlSession.builder()
.addContactEndPoint(new DefaultEndPoint(
InetSocketAddress.createUnresolved("cassandra-db",9042)))
.withKeyspace(CassandraConstant.KEY_SPACE_NAME.getValue())
.build()
I use DNS name to connect but not connected, i tried with Docker IP of cassandra container, and depends-on also.
Any issue with docker-compose file?

How to find FTP Host and username and password in docker

I'm running two webs on docker both using joomla one with 127.0.0.1:8383 and another one with 127.0.0.1:8181. in the web that has the address 127.0.0.1:8383 should connect to the other one so I need to know the Host the username and the password of ftp for 127.0.0.1:8181. I didn't find any command that I can use it on docker server that is linux to find this information (FTP HOST; FTP USERNAME; FTP PASSWORD).
docker network ls return
NETWORK ID NAME DRIVER SCOPE
f37b31437406 bridge bridge local
6677ac044ead host host local
57d840968a45 none null local
461f00275394 site_default bridge local
3ea97a6df8a8 sitea1_default bridge local
127.0.0.1:8181 docker-compose.yml
version: '3.1'
services:
web:
build:
context: ./
dockerfile: docker/web/Dockerfile
restart: always
ports:
- "8181:80"
volumes:
- .:/alpha
phpmyadmin:
image: phpmyadmin/phpmyadmin
depends_on:
- mysql
ports:
- "8282:80"
environment:
PMA_HOST: mysql
MYSQL_ROOT_PASSWORD: alpha
mysql:
build:
context: ./
dockerfile: docker/database/Dockerfile
restart: always
environment:
MYSQL_ROOT_PASSWORD: alpha
MYSQL_DATABASE: alpha
MYSQL_USER: alpha
MYSQL_PASSWORD: alpha
volumes:
- my-db:/var/lib/mysql
volumes:
my-db:
127.0.0.1:8383 docker-compose.yml
version: '3.1'
services:
joomla:
image: joomla
restart: always
links:
- joomladb:mysql
ports:
- 8383:80
volumes:
- "./:/var/www/html"
environment:
JOOMLA_DB_HOST: joomladb
JOOMLA_DB_PASSWORD: alpha
joomladb:
image: mysql:5.6
ports:
- 3306
restart: always
volumes:
- "./data:/var/lib/mysql"
environment:
MYSQL_ROOT_PASSWORD: alpha
MYSQL_DATABASE: alpha
MYSQL_USER: alpha
I already installed ftp on server
sudo apt-get update
sudo apt-get install vsftpd
The question is unclear and it does not exist any FTP command in docker.
A best practice is to create a new FTP container and linking it to your web app container.

Docker Postgres service doesn't allow me to connect to it

I created a docker-composer.yml file in which I added a Postgres service (v10.6). Everything goes smooth, but when I'm trying to connect ti it with the User: postgres and Password: postgres I get the following error:
psql: FATAL: password authentication failed for user "docker"
My code is:
version: '2'
services:
postgres:
container_name: "egn-postgres"
image: "postgres:10.6"
restart: always
ports:
- "${DB_PORT}:${DB_PORT}"
What can I do?
I think you forgot to put the environment variables, try this
version: '2'
services:
postgres:
container_name: "egn-postgres"
image: "postgres:10.6"
restart: always
ports:
- "${DB_PORT}:${DB_PORT}"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
As #RickoThePow says, you have to define the environment variables.
You can use the solution presented by him:
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
or use a separated file (postgres.env) with:
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=postgres
and then invoke the file in docker-compose file like:
version: '2'
services:
postgres:
container_name: "egn-postgres"
image: "postgres:10.6"
.
.
.
env_file: postgres.env

How to use MySQL and Flask-PonyORM App with docker-compose?

I'm having a trouble on how to configure my application to integrate Flask, PonyORM, and MySQL using docker and docker-compose.
This is my .yml file:
version: '3.1'
services:
mysql:
image: mysql
restart: always
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: kofre.db
adminer:
image: adminer
restart: always
ports:
- 8080:8080
python:
build: .
volumes:
- .:/kofre-app
ports:
- 5000:5000
depends_on:
- mysql
This is my Dockerfile:
FROM python:3
ENV PYTHONBUFFERED 1
RUN mkdir /kofre-app
WORKDIR /kofre-app
COPY setup.py /kofre-app/
RUN python setup.py install
COPY . /kofre-app/
CMD [ "python", "./run.py" ]
and this is a part of my Pony initialization script:
app = Flask(__name__)
app.config.from_object('config')
db = Database()
db.bind(provider = 'mysql', host = 'mysql', user = 'root', passwd = 'root', db = 'kofre.db')
My problems:
Sometimes when I run the command docker-compose up I'm getting the message: "Can't connect to MySQL server on 'mysql' (timed out)". Is it a proble with PonyORM? Should I use another framework?
And sometimes, the mysql service seems to lock the prompt and nothing happens after that.
Could someone help me with this problems? I'd appreciate your help.
After a lot of search and tries, I finally got it working. My problem was the incorrect sintax in my docker-compose.yml in the section of the environment of the mysql container.
Now, my newer docker-compose.yml looks like this:
version: '3'
services:
python:
build: .
container_name: python
volumes:
- .:/kofre-app
ports:
- 5000:5000
links:
- mysql
adminer:
image: adminer
container_name: adminer
ports:
- 8000:8080
links:
- mysql
mysql:
image: mysql:5.6
container_name: mysql
restart: always
ports:
- 3306:3306
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=kofre.db
- MYSQL_USER=root
- MYSQL_PASSWORD=root
The answer to this problem I found here in this another answer

Resources