Hi, I am trying to use docker compose in swarm, I created the swarm by "docker swarm init --advertise-addr " based on the tutorial in https://docs.docker.com/engine/swarm/swarm-tutorial/, which does not use docker machine (and virtualbox) for the swarm setup. After swarm manager created, I saw “swarm” is active in the “docker info” command. Then I tried to use docker compose to create containers, it seems docker compose can’t recognize that it is in the swarm mode, since docker compose can’t find the overlay network specified in the compose yml, if I specify a bridge network in the compose yml file, docker compose finds it. Very appreciate if any docker experts can share the experience when use compose inside swarm without docker machine and virtualbox. Thanks for the help.
Here are the commands I have run:
wangy@csx00309:~/containerized-bpm$ docker info
…
Server Version: 1.12.1
…
Swarm: active
NodeID: 0kwpdn6115w11vemafnvhbe7g
Is Manager: true
ClusterID: 8ftgud0oeuhx9ji43nbkhu5ag
Managers: 1
Nodes: 2
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Heartbeat Tick: 1
Election Tick: 3
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Node Address: 9.28.167.53
…
wangy@csx00309:~/containerized-bpm$ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
0kwpdn6115w11vemafnvhbe7g * csx00309 Ready Active Leader
c9gr7kg3jlo2v0vbgivsjdfne csx00310 Ready Active
wangy@csx00309:~/containerized-bpm$ docker network create --driver overlay test_network1
5w2e1o5xtqr23ehim5202t4ep
wangy@csx00309:~/containerized-bpm$ docker network ls
NETWORK ID NAME DRIVER SCOPE
05969248335e bridge bridge local
e9b2b25b0c13 docker_gwbridge bridge local
d1913ced2cec host host local
eitc6dt5htlu ingress overlay swarm
a33a1d824dc4 none null local
5w2e1o5xtqr2 test_network1 overlay swarm
wangy@csx00309:~/containerized-bpm$ more test.yml
version: '2’
services:
node1:
image: ubuntu:14.04
mem_limit: 512M
hostname: node1
container_name: node1
command: /bin/bash
networks:
- network1
networks:
network1:
driver: overlay
wangy@csx00309:~/containerized-bpm$ docker-compose -p test create
Creating node1
ERROR: Cannot create container for service node1: network test_network1 not found