我正在尝试从安装Java 8的Ubuntu 14.04构建基础Docker镜像。这是我到目前为止所拥有的:
FROM ubuntu:14.04
MAINTAINER Me Myself <memyself@example.com>
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
当我运行docker build -t memyself/docker_sample .
时,我在安装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 <memyself@example.com>
---> 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
知道我哪里出错了吗?
我添加了apt-get install -y software-properties-common
行,现在我获得了巨大的输出量,其中一些是:
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)
重要的是要注意,如果我尝试在Mac上启动多个其他图像(从Docker Hub中提取),我会得到类似的信息&#34; 设备上没有剩余空间< / EM>&#34;错误。所以我认为这个最新的问题可能是因为没有为我的机器上的Docker分配足够的空间(类似于JVM OutOfMemoryException
问题)。
答案 0 :(得分:17)
docker存储文件的文件系统已满。这就是解压缩下载的java archieve时tar崩溃的原因。
docker info
会显示文件的位置,例如
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
df -h
将告诉您文件系统上有多少磁盘空间。
使用docker ps -a
查找可以删除的容器,并使用docker rm -v
将其删除(-v
非常重要,因为它也会删除卷)。
使用docker images
查找不需要的图片,然后使用docker rmi
删除它们。
您可能拥有不再需要的悬空图像图层。使用docker rmi $(docker images -q -f dangling=true)
删除它们。
答案 1 :(得分:2)
尝试添加
apt-get install -y software-properties-common
获取add-apt-repository
。在另一个RUN
命令中或在您使用add-apt-repository
之前。
答案 2 :(得分:1)
可能是因为Docker.qcow2已满。
检查以下文件的大小
ls -lah ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
有关此文件的mac的docker上有一个未解决的问题,这是一个包含yo的稀疏图像。见https://github.com/docker/for-mac/issues/371
我遇到了同样的问题,因为我不介意重建我的容器,我只是删除了Docker.qcow2,重新启动了docker,它解决了我的问题。请小心操作,尤其是如果您有大量依赖的图像且无法重建。