I am trying to get a very simple docker-swarm going. If I start the container using docker-compose up -d
I am able to go to locahost and see the 'Hello message'.
Running docker stack deploy -c docker-compose.yml swar
starts the swarm fine.
docker ps
docker service ls
However navigating to localhost, 0.0.0.0, 127.0.0.1 or IP of machine doesn't work, it just timesout with 'This site can't be reached. took too long to respond.' Ive also tried it with another small tutorial from github, which also has same issue. Any ideas what is wrong?
server.js:
const express = require("express");
const os = require("os");
const app = express();
app.get("/", (req, res) => {
res.send("Hello from Swarm " + os.hostname());
});
app.listen(3000, () => {
console.log("Server is running on port 3000");
});
docker-compose.yml:
version: "3"
services:
web:
build: .
image: takacsmark/swarm-example:1.0
ports:
- 80:3000
networks:
- mynet
networks:
mynet:
Dockerfile:
FROM node:11.1.0-alpine
WORKDIR /home/node
COPY . .
RUN npm install
CMD npm start
EDIT: running wget < my computer ip > just hangs.
--2021-05-28 16:59:52-- http://<ip>/
Connecting to <ip>:80...
curl < ip > just hangs no output.
Ive initialised the swarm included advertise ip aswell
docker swarm init --advertise-addr <my address>
And still no luck.
My docker version is 20.10.5, docker-compose version: 1.25.0
For anyone ever getting this sort of problem. Problem was the version of docker. Ive removed 20.10.15 and reinstalled a docker 19.03.10. To install custom docker instead of latest follow steps. https://docs.docker.com/engine/install/ubuntu/
locahost doesnt work, but run hostname -I
to get the ip of your machine and paste that in. Will work then.