Linux – Due to permissions issues, in docker ubuntu :12. 04 Installing cron via apt-get in the container failed

Due to permissions issues, in docker ubuntu :12. 04 Installing cron via apt-get in the container failed… here is a solution to the problem.

Due to permissions issues, in docker ubuntu :12. 04 Installing cron via apt-get in the container failed

I’m trying to install cron (among other packages) in my Dockerfile via apt-get install.
I’ve simplified my Dockerfile to a minimum:

FROM ubuntu:12.04
RUN apt-get update
RUN apt-get install -y cron

The error I see during installation is:

Step 4 : RUN apt-get install -y cron
 ---> Running in 991339f4be58
Reading package lists...
Building dependency tree...
Reading state information...
Suggested packages:
  anacron logrotate checksecurity exim4 postfix mail-transport-agent
The following NEW packages will be installed:
  cron
0 upgraded, 1 newly installed, 0 to remove and 12 not upgraded.
Need to get 85.0 kB of archives.
After this operation, 308 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ precise-updates/main cron amd64 3.0pl1-120ubuntu4 [85.0 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 85.0 kB in 0s (204 kB/s)
Selecting previously unselected package cron.
(Reading database ... 7551 files and directories currently installed.)
Unpacking cron (from .../cron_3.0pl1-120ubuntu4_amd64.deb) ...
Setting up cron (3.0pl1-120ubuntu4) ...
Adding group `crontab' (GID 102) ...
groupadd: failure while writing changes to /etc/group
addgroup: `/usr/sbin/groupadd -g 102 crontab' returned error code 10. Exiting.
dpkg: error processing cron (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 cron
E: Sub-process /usr/bin/dpkg returned an error code (1)
2014/07/03 10:09:13 The command [/bin/sh -c apt-get install -y cron] returned a non-zero code: 100

Manually running $groupadd/etc/group inside a docker container results in the same error “groupadd: Failed to write changes to /etc/group”.

Other packages such as wget and curl install fine. Does docker need to run a process to execute groupadds? Or is there a step in Dockerfile that I’m missing that needs to happen first?

Thanks in advance.

Solution

I had to disable SELinux on a fedora machine running docker. Do setenforce 0, edit /etc/selinux/conf to disable and restart my machine to fix it. I didn’t realize that my docker container inherits the permissions issue from the machine running it.

Related Problems and Solutions