Docker Community Forums

Share and learn in the Docker community.

Can't get service to respond while following 'Getting Started' tutorial


(Navellint201) #1

I’ve been working through the “getting started” docs and everything works fine up to when I create a service in part 3; the service appears to be created but the port is unresponsive.

Running on a clean Ubuntu 17.10 Virtualbox VM. Below are the .yml file and the runs/output. (It’s the same container as was used in part 2; I run the container manually at the end of the process to demonstrate that it works.)

version: "3"
services:
  web:
    # replace username/repo:tag with your name and image details
    image: myUsername/myRepo:boogeda
    deploy:
      replicas: 5
      resources:
        limits:
          cpus: "0.1"
          memory: 50M
      restart_policy:
        condition: on-failure
    ports:
      - "3000:80"
    networks:
      - webnet
networks:
  webnet:

And the result:

me@ubuntuvm:~$ docker swarm init
Error response from daemon: This node is already part of a swarm. Use "docker swarm leave" to leave this swarm and join another one.
me@ubuntuvm:~$ docker container ls
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
me@ubuntuvm:~$ docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
me@ubuntuvm:~$ docker stack deploy -c Compose/docker-compose.yml getstartedlab4
Creating network getstartedlab4_webnet
Creating service getstartedlab4_web
me@ubuntuvm:~$ docker service ls
ID                  NAME                 MODE                REPLICAS            IMAGE                            PORTS
cxh662prxajw        getstartedlab4_web   replicated          5/5                 myUsername/myRepositry:boogeda   *:3000->80/tcp
me@ubuntuvm:~$ docker container ls
CONTAINER ID        IMAGE                            COMMAND             CREATED             STATUS              PORTS               NAMES
d4a5eddad06d        myUsername/myRepositry:boogeda   "python app.py"     36 seconds ago      Up 32 seconds       80/tcp              getstartedlab4_web.4.gr3dqmtgrbshx2yx05h6kf1j9
a39ca1f7bf2d        myUsername/myRepositry:boogeda   "python app.py"     36 seconds ago      Up 33 seconds       80/tcp              getstartedlab4_web.5.z0q0q0mk5pmqosxhktp41y2wa
11159ca196ae        myUsername/myRepositry:boogeda   "python app.py"     36 seconds ago      Up 32 seconds       80/tcp              getstartedlab4_web.3.m3jqnm6nsgr3tugufwa26abyw
b97ee7eb6529        myUsername/myRepositry:boogeda   "python app.py"     36 seconds ago      Up 33 seconds       80/tcp              getstartedlab4_web.2.u8rbewoyoa7nvjoe2osa17os5
ce88922e0d72        myUsername/myRepositry:boogeda   "python app.py"     37 seconds ago      Up 34 seconds       80/tcp              getstartedlab4_web.1.pfvv9f347cyeg80ml5inrr2kd
me@ubuntuvm:~$ curl -4 http://localhost:3000
curl: (7) Failed to connect to localhost port 3000: Connection refused
me@ubuntuvm:~$ curl -4 http://localhost:80
curl: (7) Failed to connect to localhost port 80: Connection refused
me@ubuntuvm:~$ docker container run -d -p 4000:80 myUsername/myRepositry:boogeda
af3f68c02bc593293be90b3e17eeac73e98c85c411616b1375c075d718c11a6e
me@ubuntuvm:~$ docker container ls
CONTAINER ID        IMAGE                            COMMAND             CREATED             STATUS              PORTS                  NAMES
af3f68c02bc5        myUsername/myRepositry:boogeda   "python app.py"     6 seconds ago       Up 5 seconds        0.0.0.0:4000->80/tcp   youthful_einstein
d4a5eddad06d        myUsername/myRepositry:boogeda   "python app.py"     8 minutes ago       Up 8 minutes        80/tcp                 getstartedlab4_web.4.gr3dqmtgrbshx2yx05h6kf1j9
a39ca1f7bf2d        myUsername/myRepositry:boogeda   "python app.py"     8 minutes ago       Up 8 minutes        80/tcp                 getstartedlab4_web.5.z0q0q0mk5pmqosxhktp41y2wa
11159ca196ae        myUsername/myRepositry:boogeda   "python app.py"     8 minutes ago       Up 8 minutes        80/tcp                 getstartedlab4_web.3.m3jqnm6nsgr3tugufwa26abyw
b97ee7eb6529        myUsername/myRepositry:boogeda   "python app.py"     8 minutes ago       Up 8 minutes        80/tcp                 getstartedlab4_web.2.u8rbewoyoa7nvjoe2osa17os5
ce88922e0d72        myUsername/myRepositry:boogeda   "python app.py"     8 minutes ago       Up 8 minutes        80/tcp                 getstartedlab4_web.1.pfvv9f347cyeg80ml5inrr2kd
me@ubuntuvm:~$ curl -4 http://localhost:4000
<h3>Hello World!</h3><b>Hostname:</b> af3f68c02bc5<br/><b>Visits:</b> <i>cannot connect to Redis, counter disabled.</i>me@ubuntuvm:~$ 
me@ubuntuvm:~$