Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

privileged mode in docker compose in a swarm

I am using docker-compose.yml to deploy services in a docker swarm which has cluster of raspberry pis. My services require access to the raspberry pi GPIO and needs privileged mode. I am using docker version 18.02 with docker-compose version 3.6. When I deploy the stack, I receive the following message and the services do not get deployed: "Ignoring unsupported options: privileged". Any tips? Below is my docker-compose.yml file

version: '3.6'     

networks:
    swarm_network:
        driver: overlay


services:
    service1:
        image: localrepo/img1:v0.1
        privileged: true
        deploy:
            mode: replicated
            replicas: 1
            placement:
                constraints:
                    - node.hostname == home-desktop

        ports:
            - published: 8000
              target: 8000
              mode: host

        networks:
            swarm_network:

    service2:
        image: localrepo/img1:v0.1 
        privileged: true
        deploy:
            mode: replicated
            replicas: 1

        ports:
            - published: 7000
              target: 7000
              mode: host

        networks:
            swarm_network:

    nodeViewer:
      image: alexellis2/visualizer-arm:latest
      ports:
        - "8080:8080"
      volumes:
        - "/var/run/docker.sock:/var/run/docker.sock"
      deploy:
        placement:
          constraints: [node.role == manager]
      networks:
        - swarm_network
like image 960
eth crypt Avatar asked Feb 18 '18 15:02

eth crypt


People also ask

What is privileged in Docker compose?

What is Docker Privileged Mode? Docker privileged mode grants a Docker container root capabilities to all devices on the host system. Running a container in privileged mode gives it the capabilities of its host machine. For example, it enables it to modify App Arm and SELinux configurations.

Can we use Docker compose with Docker Swarm?

Docker 1.13 introduced a new version of Docker Compose. The main feature of this release is that it allow services defined using Docker Compose files to be directly deployed to Docker Engine enabled with Swarm mode. This enables simplified deployment of multi-container application on multi-host.

How do I run a privileged container?

Create a container with a non-root user If a container is run as a non-root user, it will restrict access to many system configuration changes, even in privileged mode. Next, run this image with a privileged flag. Check PID and UID to see which user is enabled; it is user1 (non-root) with uid=1000.

What two roles can a Docker host serve as in swarm mode?

A swarm consists of multiple Docker hosts which run in swarm mode and act as managers (to manage membership and delegation) and workers (which run swarm services). A given Docker host can be a manager, a worker, or perform both roles.


1 Answers

Thats because privileged is not supported in docker swarm. I had a similar docker compose running in privileged mode but while using it to docker swarm I removed them and was working well.

That not exactly an error .For example if you use something like links or depends_on . You get similar warning message. These are just the warnings not errors.

This is how you actually check the error logs if there is any

docker service ls (to check running service) 

docker service logs servicename
like image 151
Tara Prasad Gurung Avatar answered Sep 20 '22 14:09

Tara Prasad Gurung