Failed to install a new Doker project :port is already allocated

Good afternoon dear colleagues,
I am trying to install a new Doker every things going well until this error message appear “:8080 failed: port is already allocated” (the whole Terminal text below).
what can i do to resolve this problem?
Delate the old project (I don’t really need it. It is empty. Just an installation test installed this night) Or change the the “port”? knowing that I don’t know how i can apply any of both solution.
Please not that the system is MacOS “Imac”
Thanks for your help

ERROR: for d2-cluster-23771_gateway_1 Cannot start service gateway: driver failed programming external connectivity on endpoint d2-cluster-23771_gateway_1 (8e17cddc46ffd2f31e05c8d81248f37c7dcd18525bd51b6817f2ce59fc73d6c2): Bind for 0.0.0.0:8080 failed: port is already allocated

Creating d2-cluster-23771_db_1 … done

Creating d2-cluster-23771_core_1 …

Creating d2-cluster-23771_core_1 … done

ERROR: for gateway Cannot start service gateway: driver failed programming external connectivity on endpoint d2-cluster-23771_gateway_1 (8e17cddc46ffd2f31e05c8d81248f37c7dcd18525bd51b6817f2ce59fc73d6c2): Bind for 0.0.0.0:8080 failed: port is already allocated
Encountered errors while bringing up the project.

[ERROR] Failed to spin up cluster docker-compose cluster
iMac-de-Abdalla:~ abdallatoufikhossain$ docker pull dhis2/core:2.37.7.1-tomcat-8.5.34-jre8-alpine
2.37.7.1-tomcat-8.5.34-jre8-alpine: Pulling from dhis2/core
4fe2ade4980c: Already exists
6fc58a8d4ae4: Already exists
819f4a45746c: Already exists
a05d92015b09: Already exists
78edcc4e4794: Already exists
600c3df6d57d: Already exists
210a15e81f41: Pull complete
e235408bab82: Pull complete
67e7aa3fe195: Pull complete
a8e4454f8a6a: Pull complete
f3b42377ff8f: Pull complete
4a0a6111e136: Pull complete
e9aeabf38f2a: Pull complete
Digest: sha256:9b124e33617f2e0b03e0499bdee708e3009510bb18dc24ea8c3dbf798110df57
Status: Downloaded newer image for dhis2/core:2.37.7.1-tomcat-8.5.34-jre8-alpine
docker.io/dhis2/core:2.37.7.1-tomcat-8.5.34-jre8-alpine
iMac-de-Abdalla:~ abdallatoufikhossain$

Hi

I think you can use the d2 cli command in the terminal to do that. First get the list of the available clusters:
d2 cluster list

Then you will turn the cluster down:
d2 cluster down [replace here with the cluster version you see in the list]

For example, d2 cluster down 2.37.7.1

Then when running it up, enter the command with another port number:

d2 cluster up 2.37.7.1 --port 8081

For more info please see reference: DHIS2 CLI

Dear Sharaf,
As you have kindly advised, I put all clusters DOWN and only one is UP: 2.38.1.1 (please the list in the log attached)
The problem since I have only an empty database I tried to install Sierra Leone one.

For that I follow the DHIS2 Guide : (yarn global add @dhis2/cli) and then (d2 cluster logs 2.38.1.1).

The database has started the download but never achieve the downloading as you can see from the log attached.

I would be grateful if you could identify the error and/or indicate the best way to have Sierra Leone in my programme.
Thanks again for your precious help
Abdalla

Log database Sierra Leone for 2.38.1.1.docx (595 KB)

The problem with the port being used is due to another process listening on that port. This could be related to docker or not. For example, if you are runnin Tomcat (standalone) listening on port 8080, when launching the docker containers (via d2) they Tomcat container (named d2-cluster-core or similar) will fail as by default uses that port. This can be changed in while launching the containers via d2 and specifying the port.

For injecting the database you should use the --seed option. If you have already the containers launched and don’t want to delete them your option would be download the database and injecting it via psql commands (or by a graphical tool like dbeaver or heidiSQL). In order to use this you probably will need to get the IP of the container manually and use that private IP to connect to it.

Best.

Dear Jaim,
First thanks a lot for your clear solution. I will try it now. I already deleted all the already installed clusters (Commands DOWN CLEAN). The only problem is I de not know what I should « seed » exactly. I would be grateful then if you could indicate to me:

  • The file should I use to seed;
  • Where can I find it ;
  • The procedure for seeding (commands to use in the terminal. Apologize, in fact, I don’t know how we use this command).

Thanks again and again for your kind help
Abdalla

Hi @ToufikHossain ,
You can follow steps mentioned here

The command you can use to spin up 2.37.7.1 instance with Sierra Leone DB is

d2 cluster up 2.37.7.1 --db-version 2.37.7 --seed

Also, all the available DB files are present here
https://databases.dhis2.org/

Thanks,
Rithvik

2 Likes

Dear Reddy,
First thanks a lot for your kind help.
I applied your advice as you can see below. It seems to me that I don’t know how I can « seed ». What is the procedure for seeding. I tried to copy the file just after « --seed » it never works. Could you explain please how can I seed the file correctly?
Thanks again for your help

" File “requests/adapters.py”, line 498, in send
requests.exceptions.ConnectionError: (‘Connection aborted.’, FileNotFoundError(2, ‘No such file or directory’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “docker-compose”, line 3, in
File “compose/cli/main.py”, line 81, in main
File “compose/cli/main.py”, line 200, in perform_command

File “compose/cli/command.py”, line 60, in project_from_options
File “compose/cli/command.py”, line 152, in get_project
File “compose/cli/docker_client.py”, line 41, in get_client
File “compose/cli/docker_client.py”, line 170, in docker_client
File “docker/api/client.py”, line 197, in init
File “docker/api/client.py”, line 221, in _retrieve_server_version
docker.errors.DockerException: Error while fetching server API version: (‘Connection aborted.’, FileNotFoundError(2, ‘No such file or directory’))
[7265] Failed to execute script docker-compose

[ERROR] Failed to spin up cluster docker-compose cluster
iMac-de-Abdalla:~ abdallatoufikhossain$ »

Abdalla

.

@ToufikHossain ,

Can you let me know which command you have run?

If you run the below mentioned command,
d2 cluster up 2.37.7.1 --db-version 2.37.7 --seed
the DB will get seeded automatically. You need not explicitly provide a db file as you are providing the version of DB you would need via –db-version.

Thanks,
Rithvik

3 Likes

Good Morning Reddy
Thinks to your kind advice I succeed in importing Sierra Leone database. It works!!
Thanks again and again
Abdalla

3 Likes