docker stack deploy is not working

Hi,

I’m trying to run my docker-compose file using stack deploy but when I run it using this command, I’m not able to consume the API (it keeps loading the page eternally).

it works using: docker-compose -f docker-compose.yml up -d

not work using: docker stack deploy -c docker-compose.yml myapp

Should I change something in my docker-compose file?

Follow my docker-compose.yml.

Thanks in advance.

version: '3.3’
services:
database:
image: postgres:10.3
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=testkey
- POSTGRES_DB=Test
ports:
- "5432:5432"
volumes:
- /var/lib/postgresql/data:/var/lib/postgresql/data
api:
image: mateusleonardi/dotnetcore:latest
depends_on:
- database
ports:
- "5000:5000"
volumes:
- ./…/mydir:/app
working_dir: /app/myappdir

Is ./…/mydir accessible on all the nodes of your swarm?

Hi kinghuang,

Thanks for the reply. Last night I invested more time on that and there is no issue.

When I call docker-compose up, it’s using localhost to call, but when I use docker stack deploy, it exposes the services in 127.0.0.1… Only that!

Have a nice day.