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:

  • Docker compose postgresql service - can't create user and database during build?
  • How to determine why sigterm was sent to process running inside docker container on mesos?
  • UDP packets aren't forwarded to Node Application inside of docker container
  • .pgpass for PostgreSQL replication in Dockerized environment
  • Dockerfile COPY wildcard to only match files, not folders
  • docker aufs huge diff folder
  • 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:
    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 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:
    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.

  • How would you use Hashicorp's Nomad 'template stanza' to generate an nginx config file through the Nomad job file?
  • Docker Compose - Image name
  • Transparent proxying for all docker containers
  • Docker / how to determine link?
  • How to configure /etc/hosts to test local Docker setup
  • Warning message of deprecated link option of Docker
  • 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.