Hi, I am struggling to set this up correctly. I am trying to run an app with docker stack deploy
on a remote machine. The following app works, when I deploy it with docker swarm deploy
on my windows notebook. But when I run it on the linux cluster. I cannot connect to it. If can help me to identify the missing piece here? When I run the app locally, I get some output from curl localhost:8000
, however, not at the remote machine. There I get curl: (7) Failed to connect to localhost port 8000: Connection refused
. I also do not understand why I get a different result (app accessible, not accessible) on local and remote computer, i.e. what configuration is the disrupting element.
I tried pruning all the networks and start again from scratch.
I opened a stackoverflow question on this, but the answer that I got so far did not help me.
First, I connect to a remote server via ssh:
ssh -qy -L 8000:localhost:8000 example.com
Here, I start a web application with docker stack
, with this simple yaml
file testapp.yml
:
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- web_data:/var/www/html
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
web_data: {}
And deploy this with
docker swarm deploy -c testapp.yml testapp
Now, I get the following output with sudo docker stack services testapp
:
ID NAME MODE REPLICAS IMAGE PORTS
93rj1ialspj2 testapp_db replicated 1/1 mysql:5.7
nl18a7mr4auk testapp_wordpress replicated 1/1 wordpress:latest *:8000->80/tcp
However, when I navigate to localhost:8000
there is
This site can’t be reached. localhost refused to connect.
And curl localhost:8000
(on both systems, local and remote) returns
curl: (7) Failed to connect to localhost port 8000: Connection refused
Running docker 20.10.9 remotely and 20.10.8 locally.
To my understanding it should work like this. I have no idea where the error is.