docker-compose up“错误:处理tar文件时出错(存档/ tar:无效的tar头文件)

时间:2017-05-15 00:32:54

标签: linux docker docker-compose

我无法运行docker-compose updocker-compose build --no-cache。两者都以ERROR: Error processing tar file(archive/tar: invalid tar header)退出。

我通过运行

来解决这个问题

停止并移除容器:

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

要删除所有图像:

docker rmi $(docker images -q)

我尝试了以下内容:

  • docker-compose ps未列出任何容器或图片。

  • docker ps -a也没有列出任何容器。

  • docker image list未列出任何图片。

我在调试模式下运行dockerd,我看到了:

DEBU[0998] Calling GET /v1.22/images/codesource_buildbot/json 
ERRO[0998] Handler for GET /v1.22/images/codesource_buildbot/json returned error: No such image: codesource_buildbot

所以好像我已经设法让码头工人进入一个奇怪的状态而无法让它恢复到工作状态。

我已经尝试了docker-compose down,但这也没有帮助。

Docker版本

Client:
 Version:      17.03.1-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Mon Mar 27 17:14:09 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.03.1-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Mon Mar 27 17:14:09 2017
 OS/Arch:      linux/amd64
 Experimental: false

docker-compose版本:docker-compose版本1.12.0,build b31ff33

搬运工-compose.yml

version: '2'
services:
  buildbot:
    build: ./containers/buildbot
    ports: 
      - "8010:8010"
    volumes:
      - "./containers/buildbot/volume:/code"

Dockerfile

FROM debian:latest
WORKDIR /home
RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "python-dev"]
RUN ["apt-get", "install", "-y", "python-pip"]
RUN ["apt-get", "install", "-y", "git-all"]
RUN ["pip", "install", "--upgrade", "pip"]
RUN ["pip", "install", "--ignore-installed", "six"]
RUN ["pip", "install", "service_identity"]
RUN ["pip", "install", "buildbot[bundle]"]
CMD bash wait_for_master.sh

2 个答案:

答案 0 :(得分:2)

错误消息指出codesource_buildbot图像不存在。您必须重建它或向docker-compose.yml添加适当的build指令

编辑:

PD:你的Dockerfile有点太复杂了。你可以使用:

FROM debian:latest WORKDIR /home RUN apt-get update && \ apt-get install -y python-dev \ python-pip \ git-all && \ pip install --upgrade pip && \ pip install --ignore-installed six && \ pip install service_identity && \ pip install buildbot[bundle] CMD bash wait_for_master.sh

我会在--no-cache-dir命令中添加pip,这样就不会缓存Zip文件而且图像会更小。

答案 1 :(得分:0)

在类似的经历中,我遇到了同样的问题,我刚刚删除了我作为卷安装的所有文件夹。它发生在Ubuntu GNU / Linux运行机器上。

例如,如果我有以下docker-compose.yml(取自个人项目):

version: '2'
services:

 phpBB_dev:
  build:
    context: .
    dockerfile: Dockerfile
    args:
      XDEBUG_HOST: 172.17.0.1
      XDEBUG_PORT: 9021
      UID: 1000
      GID: 1000
  image: 'pcmagas/phpbb_dev'
  links:
    - mariadb
    - postgresql
  volumes:
    - "$SRC_PATH:/var/www/html:Z"
    - "$SRC_PATH_3_1_10:/var/www/phpBB_3_1_10:Z"
    - "$SRC_PATH_3_0_14:/var/www/phpBB_3_0_14:Z"

 nginx:
  image: nginx
  ports:
    - "5092:5092"
    - "5093:5093"
    - "5094:5094"
  links:
    - "phpBB_dev"
  volumes:
    - './nginx.conf:/etc/nginx/nginx.conf:ro'
    - './logs/dev/nginx:/var/logs'
  volumes_from:
    - 'phpBB_dev'

 mariadb:
  image: mariadb
  volumes:
    - './db/maria:/var/lib/mysql'
  ports:
    - '5434:5432'
  environment:
    MYSQL_RANDOM_ROOT_PASSWORD: "yes"
    MYSQL_ONETIME_PASSWORD: "yes"
    MYSQL_DATABASE: 'phpBB'
    MYSQL_USER: 'phpbb'
    MYSQL_PASSWORD: 'a_dummy_passwd'

 postgresql:
  image: postgres
  volumes:
    - './db/postgresql:/var/lib/postgresql/data'
  ports:
    - '3306:3306'
  environment:
    POSTGRES_DB: 'phpbb'
    POSTGRES_USER: 'phpbb'
    POSTGRES_PASSWORD: 'a_dummy_passwd'

我会删除mariadb和postgresql存储数据的文件夹./db。我也会删除nginx保存日志的./logs

一个好的经验法则(对于GNU / Linux或类似的)是遵循以下步骤:

<强>步骤1:

列出所有文件&amp;文件夹作为VOLUME挂载,并拥有所有者root和group ls -l命令

<强>步骤2:

然后使用rm -rf command

删除它们