File: get-started/part5.md, CC @johndmulhausen
I tried this a few times, but perhaps I didn't follow the tutorial correctly. I wasn't able to get Redis running until I remove the volume. Below is the docker-compose.yml file that finally worked for me. However, that won't persist data, right?
docker-compose.yml
version: "3"
services:
web:
# replace username/repo:tag with your name and image details
# this is the docker image on docker hub
image: levidurfee/get-started:part2
deploy:
replicas: 10
resources:
limits:
cpus: "0.1"
memory: 50M
restart_policy:
condition: on-failure
ports:
- "80:80"
networks:
- webnet
visualizer:
image: dockersamples/visualizer:stable
ports:
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
deploy:
placement:
constraints: [node.role == manager]
networks:
- webnet
redis:
image: redis
ports:
- "6379:6379"
deploy:
placement:
constraints: [node.role == manager]
command: redis-server --appendonly yes
networks:
- webnet
networks:
webnet:
These docs are the best I've seen in a long time. I've been able to follow along easily. Thank you!
This works
volumes:
- /root/data:/data
version: "3"
services:
web:
# replace username/repo:tag with your name and image details
# this is the docker image on docker hub
image: levidurfee/get-started:part2
deploy:
replicas: 10
resources:
limits:
cpus: "0.1"
memory: 50M
restart_policy:
condition: on-failure
ports:
- "80:80"
networks:
- webnet
visualizer:
image: dockersamples/visualizer:stable
ports:
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
deploy:
placement:
constraints: [node.role == manager]
networks:
- webnet
redis:
image: redis
ports:
- "6379:6379"
volumes:
- /root/data:/data
deploy:
placement:
constraints: [node.role == manager]
command: redis-server --appendonly yes
networks:
- webnet
networks:
webnet:
I ran into the same issue, until I realized I was jumping ahead in the tutorial and had skipped "Step 2" of the "Persist the Data" section of Part 5.
- Create a ./data directory on the manager:
docker-machine ssh myvm1 "mkdir ./data"
Once I followed that portion of the Get Started tutorial, I was able to execute the stack with redis running properly (Step 4).
Hope this is helpful!
Thank you @Tasogarre :)
In my case myvm1 unexpectedly shutdown, and it appears I need to create that folder again to make it work (it's possible the folder did not persist across VM sessions).
I just sshed in to the vm or the swarm-manager and verified that there is no "/home/docker/data" directory which is the folder supposedly used for mapping ./data folder on the host. So, I just used /home/docker for the mount point and it seemed to have done the trick for starting the redis service.
$ docker-machine ssh myvm1 "ls -ltr /home/docker"
total 0
$ ls /home/docker
ls: /home/docker: No such file or directory
$ docker-machine ssh myvm1 "ls -ltr /home/docker/data"
ls: /home/docker/data: No such file or directory
exit status 1
$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
lu8e3d6ly53l getstartedlab_redis replicated 1/1 redis:latest *:6379->6379/tcp
6pcqwk30mamu getstartedlab_visualizer replicated 1/1 dockersamples/visualizer:stable *:8080->8080/tcp
ygfeb3z1iffw getstartedlab_web replicated 5/5 arun/first:new *:80->80/tcp
Hi team,
I am getting the same error.
I am not using docker-machine. I am running "docker stack deploy" on powershell as it has been done in docker service docs.

Can any one suggest me what am i doing wrong? It is working fine if I don't use volume.
Hi team,
I am getting the same error.
I am not using docker-machine. I am running "docker stack deploy" on powershell as it has been done in docker service docs.
Can any one suggest me what am i doing wrong? It is working fine if I don't use volume.
Hi Team,
I have find the issue with my problem. Volume mounting was not working for me. I had run following command to make it work.
Most helpful comment
I ran into the same issue, until I realized I was jumping ahead in the tutorial and had skipped "Step 2" of the "Persist the Data" section of Part 5.
Once I followed that portion of the Get Started tutorial, I was able to execute the stack with redis running properly (Step 4).
Hope this is helpful!