【发布时间】: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