Docker tutorial issues

Part1 shows how to create a username/repository:tag but it doesn’t say what the :tag should be. Should it always be :tag or should it be my version #. Or something else?

I am working through the part 3 of the docker get started tutorial. Everything was working great till I needed to test my swarm with curl localhost. The hostname never changes, which makes me believe that the swarm is not working. I run all the commands shown and get all the expected results except this.

Part 4 Again the swarm issue persists. I have created the vms but cannot access them from the url or with curl. Am I just missing something? There is a Note about something here but it doesn’t explain how to do this, do I even need to?

Running on Mac Sierra V 10.12.5

1 Like

Hello @mjwrazor,

The tags can be anything under the sun but is used mainly for version numbers.

More informations is needed to help you troubleshoot your swarm issue. Maybe you could post your Dockerfile and compose.yml in the forum in code blocks for us to look over.

Thanks

@denisroy
I mean its exactly the same as the tutorial.
docker-compose.yml

 iversion: "3"
 services:
   web:
     image: mjwrazor/repository:4
     deploy:
      replicas: 5
      resources:
        limits:
          cpus: "0.1"
          memory: 50M
      restart_policy:
        condition: on-failure
    ports:
      - "80:80"
    networks:
      - webnet
networks:
  webnet:

Dockerfile

`# Use an official Python runtime as a base image
FROM python:2.7-slim

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
ADD . /app

# Install any needed packages specified in requirements.txt
RUN pip install -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"]`

There is no extension on the Dockerfile right?
I ran the commands in exact sequence given in the tutorial. I went back to do it again. When I make changes do I need to bump the tag an push every time? Or can I just make changes and only create a new tag when I want to? app.py is exact copy of the tutorial code.

When I try docker swarm init after restarting I get

Error response from daemon: This node is already part of a swarm. Use "docker swarm l join another one.

No extension, that’s correct.

Error response from daemon: This node is already part of a swarm. Use "docker swarm l join another one.

That happens when you run docker swarm init more than once. If you need to restart the tutorial, you must leave the initialized swarm with:

$ docker swarm leave --force

And then you may run docker swarm init again. You should then get the following output:

$ docker swarm init

  Swarm initialized: current node ({node_name}) is now a manager.

  To add a worker to this swarm, run the following command:

      docker swarm join \
      --token {token} \
      {ip}:{port}

  To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

And then you can try and deploy your app again

Still the same response. I only ever get the same container ID it never load balances. @denisroy. Fallowing the tutorial step by step. It shows I have 5 instances if I use docker stack ps getstartedlab using the browser or curl will only ever show the same string.

Trying it on my end seems to work without a itch

Other than cleaning everything up and restarting I’m afraid I can’t be of any more counsel to you unfortunately.

docker stack rm {app(s)}
docker swarm leave --force
docker container rm {container(s)}
docker image rm {image(s)}

Im also having problems. It was working at part 2, but the part 3 which introduces docker swarm doesnt work. My docker-compose.yml and Dockerfile are the same as the tutorial. Im getting the usual connected refused at localhost:4000 and localhost:80.

I am using ubuntu 16.04. I have apache installed so it was using port 80, but i put down the apache service and the swarm still doenst work. The services are up though, because using comands like docker container ls, docker service ls, and docker inspect respond just like the tutorial. So i think its a port mapping issue.

Hi there! Part 3 “Services”… all is running and fine BUT why my service is SIGNIFICANTLY slower than my container?

Response from service:

curl -o /dev/null -s -w %{time_total}\\n  http://localhost
40.049

Response just from running container (tutorial part 2):

curl -o /dev/null -s -w %{time_total}\\n  http://localhost
0.005

So can anyone explain to me wtf? =)

Hello guys,

I ran in the same issue, I didn’t investigate too much yet but I was getting nothing out of localhost (hitting port 80).
So, if you want to progress in the tutorial, go in docker-compose.yml and change:

  • “80:80"
    by
    "4000:80”

Then hit localhost:4000

I’ll update if I find something but I believe my port 80 might be busy handling something else

1 Like

Had the same issue. Apparently, there is a bug where the port is still allocated:

So, I had to restart Docker. For Mac, literally, quit and start again.

Hi Guys, I had the same issue with tutorial Part3, I could not curl localhost. Solution for me was just restart Docker in my Mac, …works properly now :slight_smile:

This worked for me also on windows 10

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.

got the same issue for the part 4

Ran into the same issue for Part 4. I tried on both Win10 and Ubuntu 16.04. Why have nobody given out the solution for half a year? It is a just easy tutorial.

mjwrazor, I am having this same kind of issue. If you find your solution. Please suggest it.

Thankyou,
kissanime

I’m running into the exact same issue with as alacariere, with the exact same reproduction. Just to confirm that this is not an isolated issue.

macOS 10.14.1 (18B75)

❯ docker --version
Docker version 18.09.0-ce, build 4d60db4

❯ docker-machine --version
docker-machine version 0.16.0, build 702c267

❯ VirtualBox --help
Oracle VM VirtualBox Manager 5.2.22

Ok, I found a solution. Rather than going to any of the IPs coming from docker-machine or docker swarm, I just ran ifconfig on my host machine and found a vboxnet[number] that I guessed corresponded to the virtualbox machine that docker-machine was running. curling to this IP address (versus localhost or any of the other ones) was successful.

macOS 10.13.6 (17G3025)
Docker version 18.09.0, build 4d60db4
docker-machine version 0.16.0, build 702c267f
Oracle VM VirtualBox Manager 5.2.22

On tutorial steps 4 and 5, once I run:

docker stack deploy -c docker-compose.yml getstartedlab

I don’t get any errors in the console, but the URL simply does not work (generic failed to connect errors). Used curl and different browsers. I’ve tried a variety of ports, including all of the default values, and nothing works.

1 Like

Hi there,

I’m having the same issue. Here are running machines and vm1 is the swarm manager:

ubuntu18_10@ubuntu:~$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
myvm1 - virtualbox Running tcp://192.168.99.100:2376 v18.09.0
myvm2 - virtualbox Running tcp://192.168.99.102:2376 v18.09.0
myvm3 - virtualbox Running tcp://192.168.99.101:2376 v18.09.0

When I open 192.168.99.100 on Firefox, it displays this:

image

Seems weird issue :thinking:

Edit1: I’ve just found the solution right here:Get Started part 4 connection refused from node on virtual machine - #12 by andreasnilsen . Seems that was due to version of boot2docker.iso

1 Like