Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to access docker service in localhost

I creates a simple service with docker image. how I want to access it in localhost of my system.

docker service create --name my-app --replicas 3 -p 9090:8000 my-app-image



docker service ls

ID             NAME      MODE         REPLICAS   IMAGE                 PORTS
ojvi1m6f8b41   my-app    replicated   3/3        my-app-image:latest   *:9090->8000/tcp



docker ps

CONTAINER ID   IMAGE                 COMMAND                CREATED          STATUS          PORTS      NAMES
92b7d0ee0732   my-app-image:latest   "java -jar /app.jar"   39 seconds ago   Up 33 seconds   9090/tcp   my-app.2.corp0f0uln0ng4h9lrk6h09nl
4478d716939a   my-app-image:latest   "java -jar /app.jar"   39 seconds ago   Up 33 seconds   9090/tcp   my-app.1.v3wwxp1xz93sfonimg1uszaqz
52aab839c268   my-app-image:latest   "java -jar /app.jar"   39 seconds ago   Up 34 seconds   9090/tcp   my-app.3.ihpy62i331h48b1mtuhr87z46

it seems service is running but I can not access it in http://localhost:8000

Please help

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

you could access it in http://localhost:9090.
8000 is the port inside your docker container not accessible from outside.
The local port is 9090

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading