I work with the container on which ZooKeeper will be running, but I have problems with permissions on the host volumes that I mount in my container.
This is my setup:
On the host machine (Ubuntu 14.04):
- Created a user of the system "zookeeper" (id = 106) and a group (id = 111).
- Created the directory "/ var / log / zookeeper" and set its ownership of zookeeper (for example, chown zookeeper: zookeeper). This is the directory that I will install in my container.
Inside the container (Ubuntu 14.04):
- Also created a user of the system "zookeeper" (id = 102) and group (id = 105), which I use as the user from which the command is executed in ENTRYPOINT.
- Create the same directory "/ var / log / zookeeper" that will be installed, and also set its ownership of zookeeper: zookeeper (although I don't think that matters).
As soon as I start my container with mount / var / log / zookeeper, and I open the shell inside the container as the user zookeeper (which was created inside the container), I find that I get "Permission Denied" "if I try to create a file in mounted directory / var / log / zookeeper. When I do "ls -l" to look at the ownership of this directory (still inside the container), it looks something like this:
drwxr-xr-x 2 106 111 4096 Jun 30 17:18 zookeeper
106 and 111 in this case correspond to the zookeeper user and the group IDs of the host machine, which, in my opinion, are where the problem is. I tried to open the shell inside the container, but this time I logged in as the root user, and the script described above worked fine, only this root was the owner of the created file (which was expected).
From this, I came to the conclusion that I need:
(a) Run the application inside my container as a regular root user instead of the zookeeper user that I create.
(b) Create a user and a zookeeper group, both on my host computer and inside the container whose identifiers match exactly.
None of the options are perfect, because for (a) running the application as root can have potential security problems (from what I read anyway), and for (b) it can be very difficult to get an identifier so that match due to the fact that they may already be made by other users that have been created (which you have no control over).
Has anyone ever dealt with something like this before? Are there any other possible solutions that I could ignore?