Installing cron via apt-get fails in a docker ubuntu:12.04 container from permissions problems

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

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

The error that I’m seeing during the install process is:

  • Error when creating container with golang docker engine
  • Docker Service updatedAt timestamp
  • Supervisord does not show stdout from processes
  • Weird error when using protractor-headless image
  • How can I run a full-featured Linux distro in docker?
  • Integrating Docker-Machine with Amazon EC2
  • 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
    

    Running $ groupadd /etc/group manually inside the docker container results in the same error “groupadd: failure while writing changes to /etc/group”.

    Other packages such as wget and curl are installed fine. Is there a process that docker needs to have running to be able to perform groupadds? Or is there a step in the Dockerfile that needs to happen first that I’m missing?

    Thanks in advance.

  • Installing Older Docker Engine specifically - 1.11.0~dev
  • Shared Memory with Docker containers (docker version 1.4.1)
  • gunicorn with flask application not allowing more than one connection
  • All external DNS queries fail from within docker container
  • Docker | How can I remove all containers but a certain few
  • Cannot install inside docker container
  • One Solution collect form web for “Installing cron via apt-get fails in a docker ubuntu:12.04 container from permissions problems”

    I had to disable SELinux on my fedora machine running docker. Doing a setenforce 0, editing /etc/selinux/conf to disabled and rebooting my machine fixed it. I didn’t realize that my docker container would inherit permissions problems from the machine running it.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.