【问题标题】:Creating a local Ubuntu repository on Docker在 Docker 上创建本地 Ubuntu 存储库
【发布时间】:2018-08-24 12:21:32
【问题描述】:

我正在尝试在基于 Ubuntu 16.04 xenial 的 Docker 容器上创建本地 Ubuntu 存储库。我遵循了本教程: https://help.ubuntu.com/community/Repositories/Personal

这里是以root用户执行的步骤:

1. mkdir -p /root/repo/amd_64
2. copied all debian packages in /root/repo/amd_64
3. create the script /usr/bin/update-mydebs.sh with the following content:
#! /bin/bash
cd /root/repo/amd_64
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
4. Run the script update-mydebs.sh (I verified the Packages.gz is 
correctly created under /root/repo/amd_64)
5. Added the line in /etc/apt/source.list
deb file:/root/repo amd_64/

当我运行 apt-get update 时,我遇到了以下问题:

Get:1 file:/root/repo amd_64/ InRelease
Ign:1 file:/root/repo amd_64/ InRelease
Get:2 file:/root/repo amd_64/ Release
Ign:2 file:/root/repo amd_64/ Release
Get:3 file:/root/repo amd_64/ Packages [54.3 kB]
Ign:3 file:/root/repo amd_64/ Packages
Get:3 file:/root/repo amd_64/ Packages
Ign:3 file:/root/repo amd_64/ Packages
Get:3 file:/root/repo amd_64/ Packages
Ign:3 file:/root/repo amd_64/ Packages
Get:3 file:/root/repo amd_64/ Packages
Ign:3 file:/root/repo amd_64/ Packages
Get:3 file:/root/repo amd_64/ Packages
Ign:3 file:/root/repo amd_64/ Packages
Get:3 file:/root/repo amd_64/ Packages
Err:3 file:/root/repo amd_64/ Packages
File not found - /root/repo/amd_64/Packages (2: No such file or 
directory)
Reading package lists... Done
N: Can't drop privileges for downloading as file 
'/root/repo/amd_64/InRelease' couldn't be accessed by user '_apt'. - 
pkgAcquire::Run (13: Permission denied)
W: The repository 'file:/root/repo amd_64/ Release' does not have a 
Release file.
N: Data from such a repository can't be authenticated and is therefore 
potentially dangerous to use. 
N: See apt-secure(8) manpage for repository creation and user 
configuration details.
E: Failed to fetch file:/root/repo/amd_64/Packages  File not found - 
/root/repo/amd_64/Packages (2: No such file or directory)

试图解决这个问题,只需解压 /root/repo/amd_64/Packages 中的 /root/repo/amd_64/Packages.gz,文件未找到的问题已解决,但出现另一个错误:

Get:3 file:/root/repo amd_64/ Packages [169 kB]
Err:3 file:/root/repo amd_64/ Packages
    Could not open file 
    /var/lib/apt/lists/partial/_root_repo_amd%5f64_Packages - open 
    (13: Permission denied)
Reading package lists... Done
N: Can't drop privileges for downloading as file 
'/root/repo/amd_64/InRelease' couldn't be accessed by user '_apt'. - 
pkgAcquire::Run (13: Permission denied)
W: The repository 'file:/root/repo amd_64/ Release' does not have a 
Release file.
N: Data from such a repository can't be authenticated and is therefore 
potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user c 
configuration details.
E: Failed to fetch 
store:/var/lib/apt/lists/partial/_root_repo_amd%5f64_Packages  Could 
not open file /var/lib/apt/lists/partial/_root_repo_amd%5f64_Packages 
- open (13: Permission denied)
E: Some index files failed to download. They have been ignored, or old 
ones used instead.

我注意到网上所有关于这个主题的教程都与我链接的教程相似,所以我认为它是正确的,但是当我们在 Docker 容器上应用该过程时,可能有一些必须更改的地方。 有人可以帮忙吗?

【问题讨论】:

  • 您是否有可以分享的Dockerfile,以便其他人可以尝试重现您的问题? /root/repo 是烘焙到映像中的目录、绑定安装的主机目录还是其他什么?看起来您收到了非常清晰的错误消息,因此修复权限错误的复制也会有所帮助。
  • Dockerfile 是这样的: FROM ubuntu:16.04 RUN apt-get update && apt-get install -y wget git xz-utils openssh-server \ systemd-services libsensors4 gcc ENTRYPOINT service ssh start && /bin/bash 暴露 22
  • 当我启动容器时,我只有 /root,root/repo 是手动创建的。这些文件夹上没有绑定挂载。

标签: docker ubuntu ubuntu-16.04 apt


【解决方案1】:

我也有这个问题。花了我很多搜索才能找到: https://github.com/radeno/polyfill-service-docker/blob/master/Dockerfile

附注:

# work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes")
#   Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
#   ...
#   E: Failed to fetch store:/var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages  Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)

作为更新命令的一部分添加后,这对本地存储库按预期工作。

【讨论】:

    猜你喜欢
    • 2012-07-10
    • 1970-01-01
    • 2012-11-29
    • 2015-10-19
    • 1970-01-01
    • 2014-03-23
    • 2011-02-23
    • 2015-08-19
    • 2018-04-30
    相关资源
    最近更新 更多