How to use containerized PostgreSQL - postgresql

I watched Frank P Moely's video "Learning JDBC" in Lynda. I also have some difficulties to follow the steps.
For example, in "using containerized postgreSQL, I copied the command in README Run docker image
"docker run --rm --name lil-postgres -e POSTGRES_PASSWORD=password -d
-v $HOME/srv/postgres:/var/lib/postgresql/data -p 5432:5432 postgres", but it displayed as below:
"3e26ac7466c8aec1910ae87e7bf4fff30202978e392217ae98aaa85f7f76b182
docker: Error response from daemon: driver failed programming external
connectivity on endpoint lil-postgres
(28bef8efc172f5e5399bd235290fd014cacdebf5fa482dec9af204fbbbe26770):
Error starting userland proxy: listen tcp 0.0.0.0:5432: bind: address
already in use." Besides, when I ran "Creating starter data", "psql
-h localhost -U postgres -f database.sql", and it said that "database.sql: No such file or directory"
I am using Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
and I also installed Docker and postgreSQL, and I do not know how to solve the problem above. Can someone help me out? Thank you so much.

Related

Can't run docker image with MongoDB

I'm using Docker+MongoDB to run a Personal Project (tutorial i'm learning from). It worked flawlessly yesterday, but i had to restart my computer today.
Now i can't get it up & running again. I'm always having the error (according to the logs):
EDIT: The same error happens when i try to run it locally also (just compiling and checking on Postman if i can run any query). Its the same error message.
EDIT2: After running:
docker run -d --rm --name mongo -p 27017:27017 -v mongodbdata:/data/db
mongo
I got it working locally. However, i still can't get it running using the docker image.
Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HML25FGS5AM1", Request id "0HML25FGS5AM1:00000002": An unhandled exception was thrown by the
application.
System.TimeoutException: A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors =
MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector,
LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000
}, OperationsCountServerSelector }. Client view of cluster state is {
ClusterId : "1", Type : "Unknown", State : "Disconnected", Servers :
[{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/mongo:27017"
}", EndPoint: "Unspecified/mongo:27017", ReasonChanged: "Heartbeat",
State: "Disconnected", ServerVersion: , TopologyVersion: , Type:
"Unknown", HeartbeatException:
"MongoDB.Driver.MongoConnectionException: An exception occurred while
opening a connection to the server.
Here's what i can tell:
MongoDB is running. On Visual Studio using Mongo Extension, i can see that my mongo database is connected.
When i open docker for windows, i can see my image there as well. And if i hover the mouse under docker icon on notification tray, it says that docker is running.
My connection string seems to be okay. I couldn't figure out any problem with that, since its the same that was working yesterday.
I'm a bit of lost here, i don't know what else to do. It would be really really painful to restart the entire tutorial because of this docker error.
Here is my connection string:
$"mongodb://{User}:{Password}#{Host}:{Port}";
The command i'm using under the cli to run my docker image is:
docker run -it --rm -p 8080:80 -e MongoDbSettings:Host=mongo -e
MongoDbSettings:Password=Pass#word1 --network=net5tutorial
pablobhz/catalog:v1
Any input is appreciated. Thanks a lot!
Well, i fixed the problem myself. Here's what i did:
Followed the suggestion from user barrypicker . It didn't worked out but gave me an clean start.
Created a new docker file and changed it accordingly (only minor changes).
Created the mongodb container again. Here's what i did:
docker run -d --rm --name mongo -p 27017:27017 -v mongodbdata:/data/db mongo
Fine. Now i have the mongo container running again.
Built my docker image again:
docker build -t catalog:v1 .
Tried to create the docker network again. Since it already existed, just received a message saying it exists. So far so good.
Started the mongo container again. I understood that i had to start in order to my docker image works. It can't connect to an database if there's none running.
docker run -d --rm --name mongo -p 27017:27017 -v mongodbdata:/data/db
/e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e
MONGO_INITDB_ROOT_PASSWORD=Pass#word1 --network=net5tutorial mongo
Started the main container again:
docker run --it --rm -p 8080:80 -e MongoDbSettings:Host=mongo -e
MongoDbSettings:Password=Pass#word1 --network=net5tutorial catalog:v1
Hope this helps someone in the future! Sorry fot eh explanation not being great, its my first time with Docker and i've been into a lot of trial and error to get it working.
Thanks everyone!

connecting pgAdmin4 docker to postgres instance- server dialog not showing

I'm new to docker and pgAdmin.
I am trying to create a server on pgAdmin4. However, I cannot see the Server dialog when I click on "Create" in pgAdmin. I only see Server Group (image below).
Here's what I'm doing in the command prompt:
Script to connect and create image for postgres:
docker run -it -e POSTGRES_USER="root" -e POSTGRES_PASSWORD="root" -e POSTGRES_DB="ny_taxi" -v "c://Users//bpatel//data-engineering-zoomcamp//week_1_basics_n_setup//2_docker_sql//ny_taxi_data:/var/lib/postgresql/data" -p 5431:5432 postgres:13
Script to run pgAdmin after postgres is running:
docker run -it -e PGADMIN_DEFAULT_EMAIL="admin#admin.com" -e PGADMIN_DEFAULT_PASSWORD="root" -p 8080:80 dpage/pgadmin4
I am using localhost:8080 in my browser to open pgAdmin. When I try to create a new server, I only see "Server Group" option. But I need the "Server" dialog. Image for reference:
I'm not sure what I am missing? Please help! Thank you!!
They recently changed "create server" to "register server", to more accurately reflect what it actually does. Be sure to read the docs for the same version of the software as you are actually using.

Running a Chainlink Node - Remote DATABASE_URL Config PostgreSQL problem

I have been trying since yesterday to connect to a ChainLink node and I was not able to.
I followed the steps at this website
I am having a problem with "Set the Remote DATABASE_URL Config" (I think that this is my only error because of the [ERROR] listed below, I do not know if I am doing something else wrong since every command was executed without error)
I am using the Docker option to create the database listed here.
I am always having this error:
"[ERROR] unable to lock ORM: failed to connect to host=localhost user=some-postgres database=postgres: dial error (dial tcp [::1]:5432: connect: cannot assign requested address) logger/default.go:155 stacktrace=github.com/smartcontractkit/chainlink/core/logger.Errorf
/chainlink/core/logger/default.go:155"
After writing in my Ubuntu Terminal (ON WINDOWS 10):
"cd ~/.chainlink-kovan && docker run -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink:0.10.1 local n"
I do not know how to connect to the database and what to write as attributes. All of the other steps and installs I have accomplished successfully.
I just want to know how to create a database on PostgreSQL and connect it to Docker as explained on the ChainLink website and write the appropriate command in the Ubunto terminal (for the "Remote DATABASE_URL Config PostgreSQL" step) so that I can run my node.
Thanks! (PS: I am a beginner and your help is much appreciated, and if I forgot to mention any important information please let me know so that I add it)
A comprehensive 101 for docker-postgres can be found here: https://hackernoon.com/dont-install-postgres-docker-pull-postgres-bee20e200198
Basically, you need to deploy a postgres db with docker
Pre-Reqs:
Create a dir for you docker/postgres:
mkdir -p $HOME/docker/volumes/postgres
Example:
docker run --rm --name pg-docker -e POSTGRES_USER=<any_desired_name> -e POSTGRES_PASSWORD=docker -e POSTGRES_DB=<any_db_name> -d -p 5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres
For postgres username, it can be anything like "super_chain" or etc.
For postgres db, it can be "chainlink"
After, docker is up and running. Just follow up the docs tut, where you need to write the DB URL to the .env file
Cheers

How to install chrony on redhat 8 minimal

Im using keycloak docker image and need to synchronize time with chrony. however I cannot install chrony, because its not in repository i assume.
I use image from https://hub.docker.com/r/jboss/keycloak
ist based on registry.access.redhat.com/ubi8-minimal
Steps to reproduce:
~$ docker run -d --rm -p 8080:8080 --name keycloak jboss/keycloak
~$ docker exec -it -u root keycloak bash
root#707c136d9c8a /]# microdnf install chrony
error: No package matches 'chrony'
I'm not able to find working repo which provides chrony for redhat 8 minimal
Apparently i need synchronize time on host system, nothing to do with container itself.. Silly me, i need a break..

Restcomm Docker Installation Issues

I'm trying to getting started with restcomm following this guide:
http://docs.telestax.com/restcomm-docker-quick-start-guide/
but I'm facing two issues at this time:
Cannot make SIP calls. After I run the docker run command my softphone (X-Lite) can register successfully with the server but when I try to call +1234 I receive 'Call failed to connect'. This is what I see in logs:
https://justpaste.it/tdjg
I also can't connect to Visual Service Designer. This is what I see:
Log:
https://justpaste.it/tdjm
The docker command that I'm using is:
docker run --rm -i -t --name=restcomm-instance -v /var/log/restcomm/:/var/log/restcomm/ -e STATIC_ADDRESS="192.168.1.150" -e ENVCONFURL="https://raw.githubusercontent.com/RestComm/Restcomm-Docker/master/scripts/restcomm_env_locally.sh" -e VOICERSS_KEY="fdf04434829e4e02addd8d54b69e6bc0" -p 80:80 -p 443:443 -p 9990:9990 -p 5060:5060 -p 5061:5061 -p 5062:5062 -p 5063:5063 -p 5060:5060/udp -p 65000-65050:65000-65050/udp restcomm/restcomm:latest
And the servo is:
Hope you can help me.
Regards
The Restcomm Docker Quick start guide has recently been updated and should now be much more straightforward to deploy Restcomm on Docker, using Docker compose.