9

I am trying to build a base Docker image from Ubuntu 14.04 that installs Java 8. Here's what I have so far:

FROM ubuntu:14.04
MAINTAINER Me Myself <[email protected]>

WORKDIR /

RUN \
    echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
    apt-get install -y software-properties-common && \
    add-apt-repository -y ppa:webupd8team/java && \
    apt-get update && \
    apt-get install -y oracle-java8-installer && \
    rm -rf /var/lib/apt/lists/* && \
    rm -rf /var/cache/oracle-jdk8-installer

When I run docker build -t memyself/docker_sample . I get the following error installing Java:

myuser@mymachine:~/sandbox/workspace/docker_sample$docker build -t memyself/docker_sample .
Sending build context to Docker daemon 127.1 MB
Step 0 : FROM ubuntu:14.04
 ---> 91e54dfb1179
Step 1 : MAINTAINER Me Myself <[email protected]>
 ---> Using cache
 ---> 070127f8f0e5
Step 2 : WORKDIR /
 ---> Using cache
 ---> d2c8a7633d41
Step 3 : RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select
true | debconf-set-selections &&   add-apt-repository -y ppa:webupd8team/java &&
apt-get update &&   apt-get install -y oracle-java8-installer &&   rm -rf /var/lib/apt/lists/* &&   rm -rf /var/cache/oracle-jdk8-installer
 ---> Running in 548fc192e112
/bin/sh: 1: add-apt-repository: not found
The command '/bin/sh -c echo oracle-java8-installer
shared/accepted-oracle-license-v1-1 select true | debconf-set-selections &&
add-apt-repository -y ppa:webupd8team/java &&   apt-get update &&
apt-get install -y oracle-java8-installer &&
rm -rf /var/lib/apt/lists/* &&   rm -rf /var/cache/oracle-jdk8-installer'     
returned a non-zero code: 127

Any idea where I'm going awry?


Update:

I added the apt-get install -y software-properties-common line and now I'm getting an enormous amount of output, some of which is:

162816K ........ ........ ........ ........ ........ ........ 93% 3.92M 2s
165888K ........ ........ ........ ........ ........ ........ 95% 5.43M 1s
168960K ........ ........ ........ ........ ........ ........ 97% 6.35M 1s
172032K ........ ........ ........ ........ ........ ........ 98% 6.09M 0s
175104K ........ ........ ........ .....                     100% 5.27M=32s

2015-09-25 15:33:33 (5.43 MB/s) - 'jdk-8u60-linux-x64.tar.gz' saved [181238643/181238643]

Download done.
Removing outdated cached downloads...
tar: jdk1.8.0_60/jre/lib/charsets.jar: Wrote only 3072 of 10240 bytes
tar: jdk1.8.0_60/jre/lib/jce.jar: Cannot write: No space left on device
tar: jdk1.8.0_60/jre/lib/amd64/libbci.so: Cannot write: No space left on device
tar: jdk1.8.0_60/jre/lib/amd64/libjavafx_font_freetype.so: Cannot write: No space left on device
tar: jdk1.8.0_60/jre/lib/amd64/libawt_headless.so: Cannot write: No space left on device
tar: jdk1.8.0_60/jre/lib/amd64/libdt_socket.so: Cannot write: No space left on device
tar: jdk1.8.0_60/jre/lib/amd64/libmlib_image.so: Cannot write: No space left on device
...Huge amount of output omitted for brevity...
tar: jdk1.8.0_60/bin/jvisualvm: Cannot write: No space left on device
tar: jdk1.8.0_60/bin/jcontrol: Cannot write: No space left on device
tar: jdk1.8.0_60/release: Cannot write: No space left on device
tar: Exiting with failure status due to previous errors
cannot unpack jdk8
Oracle JDK 8 is NOT installed.
debconf: DbDriver "config": could not write /var/cache/debconf/config.dat-new: No space left on device
dpkg: error processing package oracle-java8-installer (--configure):
    subprocess installed post-installation script returned error exit status 1
Setting up gsfonts (1:8.11+urwcyr1.0.7~pre44-4.2ubuntu1) ...
dpkg: unrecoverable fatal error, aborting:
    unable to flush /var/lib/dpkg/updates/tmp.i after padding: No space left on device
E: Sub-process /usr/bin/dpkg returned an error code (2)

It is important to note that if I try to start up more than a few other images (pulled from Docker Hub) on my Mac, I get similar "No space left on device" errors. So I believe this latest problem is perhaps due to not allocating enough space for Docker on my machine (similar to a JVM OutOfMemoryException issue).

1
  • Please check whether there is enough space in your virtual machine. You can do so by ssh into the vm via docker-machine ssh <machine-name>. If you use the default installation of docker toolbox your machine name will be default. When you are in the machine you call df -h. The relevant output is the line starting with /dev/sda1/. If the value in column Use% is near to 100, your virtual disk is full. In that case you can start removing containers and images or increase the disk size. Please report back your findings. Commented Sep 28, 2015 at 21:22

3 Answers 3

19
+100

Your filesystem where docker stores its files is full. That's why tar chokes when unpacking the downloaded java archieve.

docker info will show you where the files are located, e.g.

Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs

df -h will tell you how much disk space is available on your filesystems.

Use docker ps -a to find containers that can be deleted and remove them with docker rm -v (-v is important because it also removes volumes). Use docker images to find unneeded images and remove them with docker rmi.

You may have dangling image layers that are no longer needed. Delete them with docker rmi $(docker images -q -f dangling=true).

3
  • 1
    Since Docker 1.9.0 there is also an api for removing unused volumes. You can find them with docker volume ls --filter dangling=true and remove them with docker volume rm $(docker volume ls --filter dangling=true -q) Commented Mar 3, 2016 at 14:07
  • Docker 1.13.0 added dedicated commands for housekeeping. You can issue docker image prune and docker volume prune to delete unused ("dangling") images and volumes. There is also docker system prune which deletes stopped containers, unused volumes, unused networks and dangling images. The new commands ask for confirmation before actually deleting anything. Commented May 30, 2017 at 11:06
  • docker info lied to me, said Root Dir is /var/lib/docker, but that directory does not exist.
    – ijt
    Commented Nov 5, 2021 at 1:32
2

try adding

apt-get install -y software-properties-common

to get add-apt-repository. Either in another RUN command or just before you use add-apt-repository.

10
  • Or add the repo manually. Don't know if it's still true but that used to bring in a bunch of python crap. Commented Sep 24, 2015 at 21:17
  • Thanks @Robert (+1) - please see my updates, any ideas? Thanks again! I guess in general I'm just sort of thunderstruck that there isn't a standard Ubuntu 14.04 and JRE 8 Docker image out there...
    – smeeb
    Commented Sep 24, 2015 at 23:23
  • @smeeb The official Java docker image is based on Debian. Close enough to Ubuntu. see: hub.docker.com/_/java Commented Sep 25, 2015 at 1:30
  • 1
    @smeeb looks like python-software-properties is no longer required, but you should also add the -y flag. I've updated my answer.
    – Robert
    Commented Sep 25, 2015 at 13:53
  • 1
    If you haven't seen the docs on increasing the disk size, here they are Commented Sep 29, 2015 at 4:51
1

It's possibly because the Docker.qcow2 is full.

Check out the size of the following file ls -lah ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2

There is an open issue on docker for mac relating to this file, which is a sparse image containing yo. See https://github.com/docker/for-mac/issues/371

I had the same issue and since I did not mind to rebuild my containers, I just deleted Docker.qcow2, restarted docker and it solved my problem. Handle with care especially if you have lots of images which you rely on and can not rebuild.

1
  • 1
    This file doesn't exist on my computer. I have a heavy Library/Containers/com.docker.docker/Data/vms/0/Docker.raw though
    – Ulysse BN
    Commented Aug 13, 2018 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.