1

Here is the docker-compose file that I once used to successfully run docker container using docker-compose.

Now trying to deploy using the docker stack. My manager and workers node are ready.

docker-compose.yml

version: '3'
services:

    prometheus:
        image: prom/prometheus
        volumes:
            - ./prometheus.yml:/etc/prometheus/prometheus.yml
        command:
            - '--config.file=/etc/prometheus/prometheus.yml'
        ports:
            - '9090:9090'
        deploy:
           mode: replicated
           replicas: 1
           placement:
               constraints:
                   - node.role == manager

Command used:

docker stack deploy -c docker-compose.yml monitoring

Trying to run it in the manager node. Why is the service not running . checking if the service is running or not using docker service ls shows 0/1 as you can see in the figure bellow.

docker service ls checking

When trying to check the logs with docker service logs <servicename> Nothing gets loaded.

Where exactly am I missing the things. My ultimate goal being running the full docker monitoring service like cadvisor and node-exporter and all other required. I tried with this https://github.com/stefanprodan/swarmprom/blob/master/docker-compose.yml

I have figured out the problem is in the replicated mode, runs well in global mode although.

What error is here with the replicated mode. I don't think I have a syntax error here. How to make it run in replicated mode and in the manager node only

Tara Prasad Gurung
  • 3,422
  • 6
  • 38
  • 76

2 Answers2

1

If everything works well with the "docker-compose up" but you find the issues with "docker stack deploy". This is how I fixed it.

I am using docker in a Windows machines and docker uses a VirtualBox VM. You will need to do port forward to see the containers in the host machine.

The problem is related to the bind mount with the volumes.

See the path in the two scenarios below when I do docker inspect :

  1. Docker-compose up:


"Mounts": [
{
"Type": "bind",
"Source": "/c/Users/Bardav/Documents/Large-Scale-Software Testing/PromptDocker/PromptDocker/app_users",
"Destination": "/app",
"Mode": "rw",
"RW": true,
"Propagation": "rprivate"
}


  1. Docker stack deploy -c docker-compose.ymal store:


"Mounts": [
{
"Type": "bind",
"Source": "C:\\Users\\Bardav\\Documents\\Large-Scale-Software Testing\\PromptDocker\\PromptDocker\\app_viewer",
"Target": "/app/"
}
],

SOLUTION:

Update the path in the docker-compose.yml and it will work. For instance;

RELATIVE PATH NOT WORKING

reg_users:
    image: prompt_user_app
    build: ./app_users/    
    volumes:
      - ./app_users/:/app/

ABSOLUTE PATH WORKS FINE

reg_users:
    image: prompt_user_app
    build: ./app_users/    
    volumes:
      - "/c/Users/Bardav/Documents/Large-Scale-Software Testing/PromptDocker/PromptDocker/app_users:/app/"
TrebledJ
  • 8,713
  • 7
  • 26
  • 48
Bartolo
  • 11
  • 2
0

This might be related to the placement constraint on Swarm Master / Manager. I had faced a similar problem while trying to schedule visualiser or portioner container on the master node using Azure Container Service. You can check the status of the master. If it is in Puased state you can make it active I had shared my experience at https://www.handsonarchitect.com/2017/11/visualize-docker-swarm-in-azure.html

Nilesh Gule
  • 1,511
  • 12
  • 13
  • It's not in the pause mode it is `active` – Tara Prasad Gurung Feb 16 '18 at 04:40
  • How many nodes do you have in the Swarm cluster? Ideally it should not matter since you are placing the constraint to schedule the container on Master. Can you check if port 9090 on the host is not used by any other service? – Nilesh Gule Feb 16 '18 at 05:34