I am new to swarm, and I am trying to get a simple service set up locally. I have set up a swarm with consul like this:
docker-machine create -d virtualbox consul
eval $(docker-machine env consul)
docker run -d -p 8500:8500 -h consul progrium/consul -server -bootstrap
docker-machine create -d virtualbox --swarm --swarm-master --swarm-discovery="consul://$(docker-machine ip consul):8500" --engine-opt="cluster-store=consul://$(docker-machine ip consul):8500" --engine-opt="cluster-advertise=eth1:2376" swarm-master
docker-machine create -d virtualbox --swarm --swarm-discovery="consul://$(docker-machine ip consul):8500" --engine-opt="cluster-store=consul://$(docker-machine ip consul):8500" --engine-opt="cluster-advertise=eth1:2376" swarm-worker
eval $(docker-machine env --swarm swarm-master)
Everything seems fine, and docker info
gives me:
Nodes: 2
swarm-master: 192.168.99.115:2376
└ ID: XRXA:2QIV:OZFX:4K3N:UF37:OWTO:TV4X:5SSE:QBGI:WDX2:ZLQS:QD7Q
└ Status: Healthy
└ Containers: 2 (2 Running, 0 Paused, 0 Stopped)
└ Reserved CPUs: 0 / 1
└ Reserved Memory: 0 B / 1.021 GiB
└ Labels: kernelversion=4.4.17-boot2docker, operatingsystem=Boot2Docker 1.12.1 (TCL 7.2); HEAD : ef7d0b4 - Thu Aug 18 21:18:06 UTC 2016, provider=virtualbox, storagedriver=aufs
└ UpdatedAt: 2016-08-29T21:10:51Z
└ ServerVersion: 1.12.1
swarm-worker: 192.168.99.116:2376
└ ID: BLNZ:TUGW:T4QQ:AUWZ:J7U3:JJTR:GHN2:SLCU:ZGRL:JGMM:LVOI:32DK
└ Status: Healthy
└ Containers: 1 (1 Running, 0 Paused, 0 Stopped)
└ Reserved CPUs: 0 / 1
└ Reserved Memory: 0 B / 1.021 GiB
└ Labels: kernelversion=4.4.17-boot2docker, operatingsystem=Boot2Docker 1.12.1 (TCL 7.2); HEAD : ef7d0b4 - Thu Aug 18 21:18:06 UTC 2016, provider=virtualbox, storagedriver=aufs
└ UpdatedAt: 2016-08-29T21:10:43Z
└ ServerVersion: 1.12.1
I can also create a network overlay:
docker network create --driver overlay my-network
docker network ls
NETWORK ID NAME DRIVER SCOPE
809a82c5c70d my-network overlay global
However, service creation will not work:
docker service create --replicas 1 --name my-web --network my-network nginx
Error response from daemon: 404 page not found
I have tried this on both the latest stable version (1.12.0) and the latest beta version (1.12.1-beta24) of docker engine with the same result. What is going on?
You are mixing up the older Docker Swarm technology setup and docker service
which is part of the newer "Swarm Mode" technology released this past June. I really wish Docker wouldn't have used the same name for what are really two different clustering technologies.
I suggest you follow this tutorial instead. https://docs.docker.com/engine/swarm/swarm-tutorial/ Consul is not needed anymore. Also when you google, make sure you search for "swarm mode". It's easy to get confused with the older stuff.