Reputation: 1
I'm trying to learn Docker, I'm using it with a 5 machine (1 leader, 4 workers) on http://play-with-docker.com and following a Udemy tutorial. I the tutorial about Docker stack, the instructor gives an example of this code:
version: "3"
services:
wordpress:
image: wordpress
depends_on:
- mysql:mysql
ports:
- 8080:80
networks:
- frontend
deploy:
replicas: 6
restart-policy:
condition: on-failure
mysql:
image: mysql
environment:
- MYSQL_ROOT_PASSWORD=password
networks:
- frontend
deploy:
placement:
constraints: [node.role == manager]
visualizer:
image: dockersamples/visualizer:stable
ports:
- 9000:8080
networks:
- frontend
stop_grace_period: 1m 30s
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
deploy:
placement:
constraints: [node.role == manager]
networks:
frontend:
He then runs it just fine in the video and everything composes properly.
I feel like I was very careful typing in his instructions, but when I run this file I get
$ docker stack deploy --compose-file docker-stack.yml wordP
service mysql: undefined network "frontend"
I've gone over this a hundred times letter by letter, space by space, line by line. I've poured through Docker's official documentation looking for something that has maybe changed betweek versions. Can anyone see an obvious problem with what I"m trying?
Thanks.
Kyle
Upvotes: 0
Views: 292
Reputation: 264701
Yaml files are space sensitive (similar to python code). The network section at the end of the file needs to be that the top level, not indented within your visualizer service.
version: "3"
services:
wordpress:
# ...
# these next lines need to be unindented 4 spaces:
networks:
frontend:
Upvotes: 2