Swarm: Manager in host + Worker in VM: No containers in workers

179 views Asked by At

I'm trying to deploy a CDN using nginx container with docker swarm. For now, i have manager in host, and one worker on VM created using docker-machine:

pierpaolo@pierpaolo-Lenovo-G580:~$ docker-machine create -d virtualbox worker1
Running pre-create checks...
Creating machine...
(worker1) Copying /home/pierpaolo/.docker/machine/cache/boot2docker.iso to /home/pierpaolo/.docker/machine/machines/worker1/boot2docker.iso...
(worker1) Creating VirtualBox VM...
(worker1) Creating SSH key...
(worker1) Starting the VM...
(worker1) Check network to re-create if needed...
(worker1) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env worker1
pierpaolo@pierpaolo-Lenovo-G580:~$ docker-machine ssh worker1
                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/
 _                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.12.5, build HEAD : fc49b1e - Fri Dec 16 12:44:49 UTC 2016
Docker version 1.12.5, build 7392c3b

I run manager on host:

pierpaolo@pierpaolo-Lenovo-G580:~$ docker swarm init
Swarm initialized: current node (99rr4i1w7wgn5usak9s20fikb) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join \
    --token SWMTKN-1-0tfvpvdlmugavn3fyqtjn9wkd3oeqze6nmw547shp07y73whix-4dqc404txwg58zibnz3lmp30w \
    192.168.1.101:2377

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

Then, on worker1, i run:

docker@worker1:~$     docker swarm join \
>     --token SWMTKN-1-0tfvpvdlmugavn3fyqtjn9wkd3oeqze6nmw547shp07y73whix-4dqc40
4txwg58zibnz3lmp30w \
>     192.168.1.101:2377
This node joined a swarm as a worker.

On host, i created overlay network:

pierpaolo@pierpaolo-Lenovo-G580:~$ docker network create -d overlay mynetwork  
cb9plmvxn6twjt5lm7xgnq4ha

And created my services, with 10 replicas:

docker service create --name nginx-cdn --network mynetwork --replicas 10 -p 9999:80 nginx-new:latest
dt1rfrix71cawpr8czzy4jje4

But, as shown as following:

pierpaolo@pierpaolo-Lenovo-G580:~$ docker service ls
ID            NAME       REPLICAS  IMAGE             COMMAND
dt1rfrix71ca  nginx-cdn  0/10      nginx-new:latest  

pierpaolo@pierpaolo-Lenovo-G580:~$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
1a64270ac470        nginx-new:latest    "nginx -g 'daemon off"   5 minutes ago       Up 5 minutes        80/tcp, 443/tcp     nginx-cdn.6.dhtgs9ilcj6jngxify7ko05e9
4a230d618e81        nginx-new:latest    "nginx -g 'daemon off"   5 minutes ago       Up 5 minutes        80/tcp, 443/tcp     nginx-cdn.4.7pnxf19kpyhf3ex31zs39q884
01a76327729e        nginx-new:latest    "nginx -g 'daemon off"   5 minutes ago       Up 5 minutes        80/tcp, 443/tcp     nginx-cdn.5.b12cp73a078mjw55gsr0x6hfn
3a940f28c532        nginx-new:latest    "nginx -g 'daemon off"   5 minutes ago       Up 5 minutes        80/tcp, 443/tcp     nginx-cdn.10.8grve8nw9fmk3tydhimh1xgng
d0e1970380d5        nginx-new:latest    "nginx -g 'daemon off"   5 minutes ago       Up 5 minutes        80/tcp, 443/tcp     nginx-cdn.1.aval6w0ol357x8obxgjzlxnxv

On manager (host) there are only 5 of 10 replicas, and on worker1

docker@worker1:~$ docker ps --all
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

There are no containers.

Why?

If i cmd docker service ps nginx-cdn there are some lines like these:

ID                         NAME              IMAGE             NODE                   DESIRED STATE  CURRENT STATE                 ERROR
aval6w0ol357x8obxgjzlxnxv  nginx-cdn.1       nginx-new:latest  pierpaolo-Lenovo-G580  Shutdown       Shutdown 7 seconds ago        
48ovjs0rvh6xceaydfjo1nx7j  nginx-cdn.2       nginx-new:latest  worker1                Shutdown       Preparing 58 seconds ago      
ayhw38h74o4m503q08gbbg3v1   \_ nginx-cdn.2   nginx-new:latest  worker1                Shutdown       Rejected about a minute ago   "No such image: nginx-new:lateā€¦"

But i created an image named "nginx-new:latest" and if i created a container from this image, it works.

0

There are 0 answers