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.
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.
Best Answer
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