Score:0

How to setup privileged in docker swarm?

ke flag

I am running a db2 container sample using this docker command. Reference docker image

docker run -itd --name mydb2 --privileged=true -p 50000:50000 -e LICENSE=accept -e DB2INST1_PASSWORD=Notallowed1! -e DBNAME=testdb ibmcom/db2

It is working. If I remove the --privileged=true I will get below error.

connection error

So, --privileged=true is mandatory.

I tried add this to docker swarm as a service using this command.

docker service create --name db2luw_1 --privileged=true -p target=50000 -e LICENSE=accept -e 'DB2INST1_PASSWORD=Notallowed1!' -e DBNAME=testdb -d ibmcom/db2

But getting this error.

unknown flag: --privileged
See 'docker service create --help'.

How to run this container in docker swarm? Removing the --privileged is creating the service but useless as we will get connection error.I tested that.

Score:0
za flag

As already said in the answer by mac, swarm mode does not support privileged mode still.

There is a hacky workaround though if you want to run privileged containers in swarm today: Just create an intermediate service which has access to the docker socket of the host, and then run a privileged container from there.

Something like the following should work:

 docker service create \
   --name mydb2-wrapper \
   --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock,ro \
   docker \
   docker run --name mydb2 --privileged=true -p 50000:50000 -e LICENSE=accept -e DB2INST1_PASSWORD=Notallowed1! -e DBNAME=testdb ibmcom/db2
Score:0
au flag
mac

Creating a service means you run your containers in swarm mode. See How services work in Docker documentation on that.

Unfortunately privileged mode doesn't work in swarm mode. As you see here the --privileged option isn't available when running docker service create

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.