Cannot connect to keycloak admin panel - docker

I've followed this tutorial and run keycloak with postgres via Docker. Since port 8080 is already in use by my front-end app, it used 9990 instead.
As the logs say:
13:26:00,602 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
13:26:00,603 INFO [org.jboss.as] (Controller Boot Thread)
WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
But when I go to these urls through my browser, nothing happens. I've also tried going to http://127.0.0.1:9990/auth/admin/ and it doesn't work to. When I try to connect, nothing appears in my keycloak console.
I've followed the tutorial without any additional settings. What's wrong?
Firstly I create a user define network:
docker network create keycloak-network
Then I run postgres:
docker run -d --name postgres --net keycloak-network -e POSTGRES_DB=keycloak -e POSTGRES_USER=keycloak -e POSTGRES_PASSWORD=password postgres
And Finally Keycloak:
docker run --name keycloak --net keycloak-network jboss/keycloak

You need to publish ports (8080 for http, 8443 for https) of the Keycloak container + remap ports, because 8080 is already used on your machine. For example:
docker run --rm \
--name keycloak \
--net keycloak-network \
-e KEYCLOAK_USER=myadmin \
-e KEYCLOAK_PASSWORD=mypassword \
-p 9990:8080 \
-p 9991:8443 \
jboss/keycloak
Keycloak admin UI will be available on:
http://<ip of the host machine\>:9990/
https://<ip of the host machine\>:9991/ (self signed cert will be generated in this case, so you will need to approve TLS exception in the browser)

If someone else like me will start his way in Docker from installing Keycloak asap.
Full path to install Keycloak on Docker and then have access to web UI via port 9990 (you can change it in last command):
docker network create keycloak-network
docker run -d --name postgres --net keycloak-network -e POSTGRES_DB=keycloak -e POSTGRES_USER=keycloak -e POSTGRES_PASSWORD=password postgres
docker run --rm --name keycloak --net keycloak-network -e KEYCLOAK_USER=myadmin -e KEYCLOAK_PASSWORD=mypassword -e DB_USER=keycloak -e DB_PASSWORD=password -p 9990:8080 -p 9991:8443 jboss/keycloak
Difference from topickstarter's and previous answer is avoiding of error below:
"WFLYCTL0113: '' is an invalid value for parameter user-name
by providing DB username and password in last command.

Related

Keycloak running in docker and connecting to local mariaDB

I try to setup keycloak as a docker container using a mariaDB Server which is installed on the host machine. The mariaDB Server should not run in a Docker container.
I try to run keycloak by this command:
docker run -d --name keycloak -p 8443:8443 -v /opt/keycloak/certs:/etc/x509/https --net staticNet --ip 172.18.0.10 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD='password' -e DB_VENDOR=mariadb -e DB_ADDR=host.docker.internal -e DB_DATABASE=keycloak -e DB_USERNAME=keycloak -e DB_PASSWORD='dbUserPassword' jboss/keycloak
The Network was created with: docker network create --subnet=172.18.0.0/16 staticNet
But keycload fails to start with error that it is not able to connect to the database host.
Is there something missing in my network Configuration? Or is something wrong with my docker run? Or do I need some special configuration for my mariaDB Server?

How to create multiple Debezium connectores for mysql database

I am tring to connect multiple Debezium connectores for a mysql database and my configurations are as follows.
sudo docker run -it --name zookeeper -p 2181:2181 -p 2888:2888 -p 3888:3888 debezium/zookeeper:1.5 &
sudo docker run -it --name kafka -p 9092:9092 --link zookeeper:zookeeper debezium/kafka:1.5 &
sudo docker run -it --name connect -p 8083:8083 -e GROUP_ID=1 -e CONFIG_STORAGE_TOPIC=my_connect_configs -e OFFSET_STORAGE_TOPIC=my_connect_offsets -e STATUS_STORAGE_TOPIC=my_connect_statuses --link zookeeper:zookeeper --link kafka:kafka debezium/connect:1.5 &
sudo docker run -it --name connect1 -p 8084:8084 -e GROUP_ID=1 -e CONFIG_STORAGE_TOPIC=my_connect_configs -e OFFSET_STORAGE_TOPIC=my_connect_offsets -e STATUS_STORAGE_TOPIC=my_connect_statuses --link zookeeper:zookeeper --link kafka:kafka debezium/connect:1.5 &
but when i tring to run second connector...following error occurred.
ERRO[0000] error waiting for container: context canceled
Can anyone help me with this please.
You're not running any connectors, only containers for workers.
One Kafka Connect worker can be used to submit more than one connector task via the HTTP server on port 8083
Regarding the commands shown, you do not need multiple containers unless you are trying to create a Connect worker cluster
In order to do so, they need the same topics and the same group id.
You'd also want -p 8084:8083 since you've not changed the server port. Also, rather than using &, you can do docker run -d, but using Docker Compose would make more sense here

You don't have permission to access / on this server docker

I want to start a container from that image:
sudo docker run --name phpldapadmin -p 2222:80 -p 2443:443 -e LDAP_HOST=ldap.example.com -e LDAP_LOGIN_DN=cn=admin,dc=example,dc=com --link openldap:ldap-host --detach osixia/phpldapadmin:0.7.0 --copy-service
But when I'm visiting my localhost:2222 I see:
Forbidden
You don't have permission to access / on this server.
So my question is: How do I have to start my container properly? What am I doing wrong here.

Connection refused when trying to run Kong API Gateway using a docker container

I am trying to run Kong API Gateway using a docker container. I followed the instructions on hub.docker.com/_/kong/, started Cassandra database and Kong.
I have Cassandra running using the below command:
docker run -d --name kong-database \
-p 9042:9042 \
cassandra:3
and Kong running using the below command:
docker run -d --name kong \
--link kong-database:kong-database \
-e "KONG_DATABASE=cassandra" \
-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
-p 8000:8000 \
-p 8443:8443 \
-p 8001:8001 \
-p 7946:7946 \
-p 7946:7946/udp \
kong:latest
Both containers are running. (I don't have enough reputations to embed pictures here right now so please see a screenshot here:
my container list)
However when I do:
$ curl http://127.0.0.1:8001
I got this:
curl: (7) Failed to connect to 127.0.0.1 port 8001: Connection refused
Can anyone let me know what is the possible reason?
Ok, check the logs of the kong container to find any errors if there are any(docker logs kong).
If there aren't any errors, please check whether there is any active process running on the port or not(sudo netstat -anp | grep 8001). That will help us know whether the docker-container port 8001 was properly binded to server port 8001 and also the ip on which the port is running.
If there is process running on that port, then it might be an issue of running docker on bridge network which is not able to bind the port with localhost. try re-running the container with network host(--net host). Then it should work fine.

How do I set up a simple dockerized RabbitMQ cluster?

I've been doing a bit of reading up about setting up a dockerized RabbitMQ cluster and google turns up all sorts of results for doing so on the same machine.
I am trying to set up a RabbitMQ cluster across multiple machines.
I have three machines with the names dockerswarmmodemaster1, dockerswarmmodemaster2 and dockerswarmmodemaster3
On the first machine (dockerswarmmodemaster1), I issue the following command:
docker run -d -p 4369:4369 -p 5671:5671 -p 5672:5672 -p 15671:15671 -p 15672:15672 \
-p 25672:25672 --hostname dockerswarmmodemaster1 --name roger_rabbit \
-e RABBITMQ_ERLANG_COOKIE='secret cookie here' rabbitmq:3-management
Now this starts up a rabbitMQ just fine, and I can go to the admin page on 15672 and see that it is working as expected.
I then SSH to my second machine (dockerswarmmodemaster2) and this is the bit I am stuck on. I have been trying variations on the following command:
docker run -d -p 4369:4369 -p 5671:5671 -p 5672:5672 -p 15671:15671 \
-p 15672:15672 -p 25672:25672 --name jessica_rabbit -e CLUSTERED=true \
-e CLUSTER_WITH=rabbit#dockerswarmmodemaster1 \
-e RABBITMQ_ERLANG_COOKIE='secret cookie here' \
rabbitmq:3-management
No matter what I try, the web page on both RabbitMQ machines says that there is no cluster under the 'cluster links' section. I haven't tried involving the third machine yet.
So - some more info:
The machine names are resolvable by DNS.
I have tried using the --net=host switch in the docker run command on both machines; no change.
I am not using docker swarm or swarm mode.
I do not have docker compose installed. I'd prefer not to use it if possible.
Is there any way of doing this from the docker run command or will I have to download the rabbit admin cli and manually join to the cluster?
You can use this plugin https://github.com/aweber/rabbitmq-autocluster to create a RabbitMQ docker cluster.
The plugin uses etcd2 or consul as service discovery, in this way you don't need to use the rabbitmqctl command line.
I used it with docker swarm, but it is not necessary.
Here is the result
The official container seems to not support environment variables CLUSTERED and CLUSTER_WITH. It supports only a list variables that are specified in RabbitMQ Configuration.
According to official Clustering Guide, one of possible solutions is via configuration file. Thus, you can just provide your own configuration to the container.
Modified default configuration in your case will look like:
[
{ rabbit, [
{ loopback_users, [ ] },
{ cluster_nodes, {['rabbit#dockerswarmmodemaster1'], disc }}
]}
].
Save this snippet to, for example, /home/user/rmq/rabbitmq.config.
Hint: If you want to see node in management console, you need to add another file /home/user/rmq/enabled_plugins with only string
[rabbitmq_management].
after that, your command will look like
docker run -d -p 4369:4369 -p 5671:5671 -p 5672:5672 -p 15671:15671 \
-p 15672:15672 -p 25672:25672 --name jessica_rabbit \
-v /home/user/rmq:/etc/rabbmitmq \
-e RABBITMQ_ERLANG_COOKIE='secret cookie here' \
rabbitmq:3-management
PS You may also need to consider setting environment variable RABBITMQ_USE_LONGNAME.
In order to create a cluster, all rabbitmq nodes that are to form up a cluster must be accessible (each one by others) by node name (hostname).
You need to specify a hostname for each docker container with --hostname option and to add /etc/host entries for all the other containers, this you can do with --add-host option or by manually editing /etc/hosts file.
So, here is the example for a 3 rabbitmq nodes cluster with docker containers (rabbitmq:3-management image).
First, create a network so that you can assign IPs: docker network create --subnet=172.18.0.0/16 mynet1. We are going to have the following:
3 docker containers named rab1con, rab2con and rab3con
IPs respectively will be 172.18.0.11 , -12 and -13
each of them will have the host name respectively rab1, rab2 and rab3
all of them must share the same erlang cookie
Spin up the first one
docker run -d --net mynet1 --ip 172.18.0.11 --hostname rab1 --add-host rab2:172.18.0.12 --add-host rab3:172.18.0.13 --name rab1con -e RABBITMQ_ERLANG_COOKIE='secret cookie here' rabbitmq:3-management
second one
docker run -d --net mynet1 --ip 172.18.0.12 --hostname rab2 --add-host rab1:172.18.0.11 --add-host rab3:172.18.0.13 --name rab2con -e RABBITMQ_ERLANG_COOKIE='secret cookie here' rabbitmq:3-management
last one
docker run -d --net mynet1 --ip 172.18.0.13 --hostname rab3 --add-host rab2:172.18.0.12 --add-host rab1:172.18.0.11 --name rab3con -e RABBITMQ_ERLANG_COOKIE='secret cookie here' rabbitmq:3-management
Then, in container rab2con, do
rabbitmqctl stop_app
rabbitmqctl join_cluster rabbit#rab1
rabbitmqctl start_app
and the same in rab3con and that's it.

Resources