I’ve had the exact same issue with the latest version of the tutorial at part 4, “Accessing your Swarm”.
I had a clean run on the tutorial (no extra images or containers, correct port configuration on docker-compose), I tried restarting Docker and no love. What do I do?
My files are quoted here, default from the tutorial.
App.py
from flask import Flask
from redis import Redis, RedisError
import os
import socket
#Connect to Redis
redis = Redis(host=“redis”, db=0, socket_connect_timeout=2, socket_timeout=2)
app = Flask(name)
@app.route(“/”)
def hello():
try:
visits = redis.incr(“counter”)
except RedisError:
visits = “cannot connect to Redis, counter disabled”
html = “Hello {name}!
”
“Hostname: {hostname}
”
“Visits: {visits}”
return html.format(name=os.getenv(“NAME”, “world”), hostname=socket.gethostname(), visits=visits)
if name == “main”:
app.run(host=‘0.0.0.0’, port=80)
docker-compose.yml
version: “3”
services:
web:
# replace username/repo:tag with your name and image details
image: alacariere/get-started:part2
deploy:
replicas: 3
resources:
limits:
cpus: “0.1”
memory: 50M
restart_policy:
condition: on-failure
ports:
- “4000:80”
networks:
- webnet
networks:
webnet:
Dockerfile
Use an official Python runtime as a parent image
FROM python:2.7-slim
Set the working directory to /app
WORKDIR /app
Copy the current directory contents into the container at /app
COPY . /app
Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt
Make port 80 available to the world outside this container
EXPOSE 80
Define environment variable
ENV NAME World
Run app.py when the container launches
CMD [“python”, “app.py”]
Terminal Response from creating VM’s until swarm created
Machine Info
I’m on a mid 2015 15inch Mac running High Sierra. Help is appreciated. Also, please note that the blockquotes wreck all of the spacing and comments from the files, but as I am not able to attach them, you have to just trust that I literally copied and pasted from the tutorial.