How to run jhipster-registry from docker? - jhipster

I'm new to jhipster, I'm trying to run jhipster-registry, but it seems I can not access it from my browser with this url:http://localhost:8761/
How did I install jhipster-registry in docker?
Install docker on mac.
docker pull jhipster/jhipster-registry
docker run jhipster/jhipster-registry
I could see everything run smoothly.
----------------------------------------------------------
Application 'jhipster-registry' is running! Access URLs:
Local: http://localhost:8761/
External: http://172.17.0.2:8761/
Profile(s): [composite, prod]
----------------------------------------------------------
2020-08-18 03:45:45.853 INFO 6 --- [ main] i.g.j.registry.JHipsterRegistryApp :
----------------------------------------------------------
Config Server: Connected to the JHipster Registry config server, using https://github.com/jhipster/jhipster-registry-sample-config !
access at http://localhost:8761/ but failed.
Any idea on this one?

In https://www.jhipster.tech/jhipster-registry/ you'll read "A docker-compose file to run this image is already present within each microservice src/main/docker directory". Did you try e.g. https://github.com/jhipster/jhipster-sample-app-microservice/blob/master/src/main/docker/jhipster-registry.yml - or your own?

It depends on the docker command you use to run the service. You must open the ports to the container.
If you just want to see the dashboard you can run this docker command
docker run -p 8761:8761 jhipster/jhipster-registry
After running this command you can type:
localhost:8761
in your browser, you should see the console.
If you want to connect the registry to other microservices, you need to set up a docker network overlay.
You can also use docker swarm or kubernetes for horizontal scaling (to make more replicas)

Related

Azure app service doesn't install docker properly

I am currently trying to start ElasticSearch on an Azure app service using Docker. I install docker through the ssh available in azure app services. Docker seem to install alright in the console, however when I run
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.6.2
I get the following error in the ssh console:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
I have installed and uninstall Docker several times, however I still get the same error
Azure App service does not allow you to run Elastic Search due to its limitations
You may use Elastic as a Service on Azure or install it in AKS or VM.
https://azuremarketplace.microsoft.com/en-us/marketplace/apps/elastic.ec-azure?tab=Overview
You are trying to install Docker inside the Docker container
App Service for Linux comes with a bunch of preconfigured containers such as Node, PHP, Java, Python, Ruby and .NET Core.
https://anthonychu.ca/post/jekyll-azure-app-service-linux/
The exact issue you mentioned means that Docker daemon is not started in your Linux environment
To start the Docker daemon use command:
systemctl start docker

userns-remap option in Docker Swarm (existing) installation

I decided to increase security by enabling userns-remap option in Docker running in swarm mode.
Installation is not new, there's plenty of running services.
Followed configuration with official manual: https://docs.docker.com/engine/security/userns-remap/
Docker service is starting but docker service ls throws error:
Handler for GET /v1.40/services returned error: This node is not a swarm manager. Use docker swarm init or docker swarm join to connect this node to swarm and try again
Error getting services: This node is not a swarm manager. Use docker swarm init or docker swarm join to connect this node to swarm and try again
cat /etc/docker/daemon.json is simple as
{
"userns-remap": "default"
}
cat /etc/subuid /etc/subgid
dockremap:100000:65536
dockremap:100000:65536
id dockremap
uid=1000(dockremap) gid=1000(dockremap) groups=1000(dockremap)
ls -ld /var/lib/docker/100000.100000/
drwx------ 11 231072 231072 26 Mar 21 20:19 /var/lib/docker/100000.100000/
Removing userns-remap from config brings services back to normal.
Running CentOS 7.7 and docker 19.03.8
How can I make it work?
From https://docs.docker.com/engine/security/userns-remap/:
Enabling userns-remap effectively masks existing image and container
layers, as well as other Docker objects within /var/lib/docker/. This
is because Docker needs to adjust the ownership of these resources and
actually stores them in a subdirectory within /var/lib/docker/. It is
best to enable this feature on a new Docker installation rather than
an existing one.
Ergo - all existing images and containers will not be available after enabling user namespace.

NodeJS in Docker doesn't see connection

I have a NodeJS/Vue app that I can run fine until I try to put it in a Docker container. I am using project structure like:
When I do npm run dev I get the output:
listmymeds#1.0.0 dev /Users/.../projects/myproject
webpack-dev-server --inline --progress --config build/webpack.dev.conf.js
and then it builds many modules before giving me the message:
DONE Compiled successfully in 8119ms
I Your application is running here: http://localhost:8080
then I am able to connect via browser at localhost:8080
Here is my Dockerfile:
FROM node:9.11.2-alpine
RUN mkdir -p /app
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
CMD npm run dev
EXPOSE 8080
I then create a docker image with docker build -t myproject . and see the image listed via docker images
I then run docker run -p 8080:8080 myproject and get a message that my application is running here: localhost:8080
However, when I either use a browser or Postman to GET localhost:8080 there is no response.
Also, when I run the container from the command line, it appears to lock up so I have to close the terminal. Not sure if that is related or not though...
UPDATE:
I trying following the Docker logs such as
docker logs --follow
and there is nothing other than the last line that my application is running on localhost:8080
This would seem to indicate that my http requests are never making into my container right?
I also tried the suggestion to
CMD node_modules/.bin/webpack-dev-server --host 0.0.0.0
but that failed to even start.
It occurred to me that perhaps there is a Docker network issue, perhaps resulting in an earlier attempt at kong api learning. So I run docker network ls and see
NETWORK ID NAME DRIVER SCOPE
1f11e97987db bridge bridge local
73e3a7ce36eb host host local
423ab7feaa3c none null local
I have been unable to stop, disconnect or remove any of these networks. I think the 'bridge' might be one Kong created, but it won't let me whack it. There are no other containers running, and I have deleted all images other than the one I am using here.
Answer
It turns out that I had this in my config/index.js:
module.exports = {
dev: {
// Various Dev Server settings
host: 'localhost',
port: 8080,
Per Joachim Schirrmacher excellent help, I changed host from localhost to 0.0.0.0 and that allowed the container to receive the requests from the host.
With a plain vanilla express.js setup this works as expected. So, it must have something to do with your Vue application.
Try the following steps to find the source of the problem:
Check if the container is started or if it exits immediately (docker ps)
If the container runs, check if the port mapping is set up correctly. It needs to be 0.0.0.0:8080->8080/tcp
Check the logs of the container (docker logs <container_name>)
Connect to the container (docker exec -it <container_name> sh) and check if node_modules exists and contains all
EDIT
Seeing your last change of your question, I recommend starting the container with the -dit options: docker run -dit -p 8080:8080 myproject to make it go to the background, so that you don't need to hard-stop it by closing the terminal.
Make sure that only one container of your image runs by inspecting docker ps.
EDIT2
After discussing the problem in chat, we found that in the Vue.js configuration there was a restriction to 'localhost'. After changing it to '0.0.0.0', connections from the container's host system are accepted as well.
With Docker version 18.03 and above it is also possible to set the host to 'host.docker.internal' to prevent connections other than from the host system.

Hyperledger Composer cannot connect with dockerized Node.js app

I am working in a POC using Hyperledger Composer v0.16.0 and Node.js SDK. I have deployed my Hyperledger Fabric instance following this developer tutorial and when I run locally my Node.js app via node server.js command it works correctly, I can retrieve participants, assets, etc.
However, when I Dockerize my Node.js app and I run the container for this app I am not able to reach the Hyperledger Fabric instance. So, how can I set the credentials to be able to reach my Hyperledger Fabric or another one since my Node.js app?
My Dockerfile looks like this:
FROM node:8.9.1
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD [ "npm", "start" ]
I run my docker/node.js image with this command:
docker run --network composer_default -p 3000:3000 -d myuser/node-web-app
There are 2 pitfalls to watch out for with Dockerizing your app. 1. Location of Cards and 2. Network Address of Fabric servers.
The Business Network Card(s) used by your app to connect to the Fabric. These cards are in a hidden folder under your default home folder e.g. /home/thatcher/.composer on a Linux machine. You need to 'pass' these into the container or share them with a shared volume as suggested by the previous answer. So running your container for the first time try adding this in the command -v ~/.composer:/home/<user>/.composer where is the name of the default user in your container. Be aware also that the folder on your Docker Host machine must allow write access to the UID of the user inside the container.
When you have sorted out the sharing of the cards you need to consider what connection information is in the card. It is quite likely that the Business Network Card you are using will be using localhost as the addresses of your Fabric servers, the port forwarding of the ports from your Docker host into the containers means that localhost is easy and works. However in your container localhost will redirect inside the container so will not see the Fabric. The arguments on the Docker command --network composer_default will set up your new container on the same Docker network as the Fabric Containers and so your Container could see the 'addresses' of the Fabric servers e.g. orderer.example.com but you card would then fail outside your container. The best way forward would be to put the IP Address number of your Docker Host machine into the connection.json file instead of localhost, and then your card would work inside and outside of your container.
So, credentials would be config info. The two ways to pass config info into a basic docker container are:
environment variables (-e)
mount a volumes (-v) with config info.
You can also have scripts that you install from Dockerfile that modify files and such.
The docker logs may give clues as to the exact problem or set of problems.
docker logs mynode
You can also enter a running container and snoop around using the command
docker exec -it mynode bash

Docker cannot login to azurecr.io

On Docker version 17.09.0-ce, build afdb6d4 (running on Mac OS 10.12.5) I'm having the following error when I run docker login <proj>.azurecr.io:
Warning: failed to get default registry endpoint from daemon (Cannot
connect to the Docker daemon at unix:///var/run/docker.sock. Is the
docker daemon running?). Using system default:
https://index.docker.io/v1/
This is after I input the username and password that I retrived using az acr. I've done this same process in the past and now it's not working anymore.
How can I debug this and login/pull images again?
Summary: I believe I just needed to restart Docker.
First, I turned on debugging by adding { "debug": true } to /etc/docker/daemon.json. Resource here. This probably wasn't needed
Second, I restarted docker from the mac terminal with osascript -e 'quit app "Docker"' followed by open -a Docker, details found here.
I suggest you need restart your docker service, please refer to this similar issue.
https://github.com/yegor256/rultor/issues/1041

Resources