Naresh Chaurasia
Naresh Chaurasia

Reputation: 469

Docker container startup hangs while trying to run voting app

I did the following:

https://github.com/dockersamples/example-voting-app

cd example-voting-app

Inside that there are number of files/folders

MAINTAINERS
LICENSE
Jenkinsfile
ExampleVotingApp.sln
README.md
docker-stack-windows-1809.yml
docker-stack-simple.yml
docker-compose.yml
docker-compose-windows.yml
docker-compose-windows-1809.yml
docker-compose-simple.yml
docker-compose-k8s.yml
docker-compose-javaworker.yml
architecture.png
kube-deployment.yml
k8s-specifications
docker-stack.yml
docker-stack-windows.yml
result
vote
worker

I did cd vote and executed following commands

docker build . -t voting-app
docker run -p 5000:80 voting-app

After I run docker run command, I see the following output, and nothing is happening . I am clueless, as there is no error messages etc.

[root@osboxes vote]# docker run -p 5000:80 voting-app
[2020-06-16 17:59:27 +0000] [1] [INFO] Starting gunicorn 19.10.0
[2020-06-16 17:59:27 +0000] [1] [INFO] Listening at: http://0.0.0.0:80 (1)
[2020-06-16 17:59:27 +0000] [1] [INFO] Using worker: sync
[2020-06-16 17:59:27 +0000] [9] [INFO] Booting worker with pid: 9
[2020-06-16 17:59:27 +0000] [10] [INFO] Booting worker with pid: 10
[2020-06-16 17:59:27 +0000] [11] [INFO] Booting worker with pid: 11
[2020-06-16 17:59:27 +0000] [12] [INFO] Booting worker with pid: 12

Please guide how to fix this issue, and how to get the vote app running on container.

My OS details are as follows:

NAME="CentOS Linux"
VERSION="7 (Core)"

Thanks

Upvotes: 0

Views: 602

Answers (2)

Naresh Chaurasia
Naresh Chaurasia

Reputation: 469

In my earlier answer, i got the app working, by building and running each image individually.

Finally, after spending few hours, I am finally able to create docker-compose.yml file and able to run the entire application using the following command:

docker-compose up

Hope it helps other who are struggling to make this application work.

docker-compose.yml

version: "3"

services:
 redis:
  image: redis

 db:
  image: postgres:9.4
  environment:
    - POSTGRES_PASSWORD=postgres
    - POSTGRES_HOST_AUTH_METHOD=trust

 vote:
  image: voting-app
  ports:
   - 5000:80
  links:
   - redis

 worker:
  image: worker-app
  links:
    - db
    - redis

 result:
  image: result-app
  ports:
    - 5001:80
  links:
    - db

Upvotes: 1

Naresh Chaurasia
Naresh Chaurasia

Reputation: 469

After code checkout, I followed the following steps, and got the voting application to run.

change to vote directory

docker run -d --name=redis redis

docker build . -t voting-app

docker run -p 5000:80 --link redis:redis voting-app

docker run -d --name=db -e POSTGRES_PASSWORD=postgres postgres:9.4

change to worker directory

docker build . -t worker-app

docker run --link redis:redis --link db:db worker-app

change to result directory

docker build . -t result-app

docker run -p 5001:80 --link db:db result-app

Access the URLs

http://<IP>:5000/

http://<IP>:5001/

Replace the IP with IP of your machine. Now I can access both the URLs.

Upvotes: 0

Related Questions