在容器中运行apt update && apt install -y sudo失败

时间:2018-10-09 00:06:03

标签: linux postgresql docker ubuntu debian

我试图在Ubuntu 16.04中站立该容器,步骤之一是:RUN apt update && apt install -y sudo

此步骤失败,并有Temporary failure to resolve个存储库。这是此错误的输出:

Step 2/8 : RUN apt update && apt install -y sudo
 ---> Running in 15215f43b522

WARNING: apt does not have a stable CLI interface yet. Use with caution in scripts.

Err http://security.debian.org jessie/updates InRelease

Err http://deb.debian.org jessie InRelease

Err http://apt.postgresql.org jessie-pgdg InRelease

Err http://security.debian.org jessie/updates Release.gpg
  Temporary failure resolving 'security.debian.org'
Err http://deb.debian.org jessie-updates InRelease

Err http://apt.postgresql.org jessie-pgdg Release.gpg
  Temporary failure resolving 'apt.postgresql.org'
Err http://deb.debian.org jessie Release.gpg
  Temporary failure resolving 'deb.debian.org'
Err http://deb.debian.org jessie-updates Release.gpg
  Temporary failure resolving 'deb.debian.org'
Reading package lists...
W: Failed to fetch http://deb.debian.org/debian/dists/jessie/InRelease  

W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/InRelease  

W: Failed to fetch http://security.debian.org/dists/jessie/updates/InRelease  

W: Failed to fetch http://apt.postgresql.org/pub/repos/apt/dists/jessie-pgdg/InRelease  

W: Failed to fetch http://security.debian.org/dists/jessie/updates/Release.gpg  Temporary failure resolving 'security.debian.org'

W: Failed to fetch http://deb.debian.org/debian/dists/jessie/Release.gpg  Temporary failure resolving 'deb.debian.org'

W: Failed to fetch http://apt.postgresql.org/pub/repos/apt/dists/jessie-pgdg/Release.gpg  Temporary failure resolving 'apt.postgresql.org'

W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/Release.gpg  Temporary failure resolving 'deb.debian.org'

W: Some index files failed to download. They have been ignored, or old ones used instead.
Building dependency tree...
Reading state information...
All packages are up to date.

WARNING: apt does not have a stable CLI interface yet. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package sudo

我能够在主机上ping仓库。但是上面的输出似乎表明这些主机无法从出现的容器中发出命令。

感谢您的帮助。

2 个答案:

答案 0 :(得分:1)

似乎int TvCtrlPointSendAction( int service, int devnum, const char *actionname, const char **param_name, char **param_val, int param_count) { struct TvDeviceNode *devnode; IXML_Document *actionNode = NULL; int rc = TV_SUCCESS; int param; ithread_mutex_lock(&DeviceListMutex); rc = TvCtrlPointGetDevice(devnum, &devnode); if (TV_SUCCESS == rc) { if (0 == param_count) { actionNode = UpnpMakeAction(actionname, TvServiceType[service], 0, NULL); } else { for (param = 0; param < param_count; param++) { if (UpnpAddToAction (&actionNode, actionname, TvServiceType[service], param_name[param], param_val[param]) != UPNP_E_SUCCESS) { SampleUtil_Print ("ERROR: TvCtrlPointSendAction: Trying to add action param\n"); /*return -1; // TBD - BAD! leaves mutex locked */ } } } rc = UpnpSendActionAsync(ctrlpt_handle, devnode->device. TvService[service].ControlURL, TvServiceType[service], NULL, actionNode, TvCtrlPointCallbackEventHandler, NULL); if (rc != UPNP_E_SUCCESS) { SampleUtil_Print("Error in UpnpSendActionAsync -- %d\n", rc); rc = TV_ERROR; } } ithread_mutex_unlock(&DeviceListMutex); if (actionNode) ixmlDocument_free(actionNode); return rc; } 无法解决。您可以尝试以下两种解决方案之一:

  1. 使用DNS启动容器。

类似--dns=xx.xx.xx.xx

  1. 在主机上更改docker run --dns=xx.xx.xx.xx images,并在修改后重新启动docker守护程序。

/etc/docker/daemon.json中添加以下内容:

daemon.json

答案 1 :(得分:0)

由于apt会随版本更改其行为(请参见man apt中的描述),因此在命令行中输入apt upgrade会将您带到最新版本,并且最有可能解决问题连接到存储库。但是,请按照以下步骤操作,以确保您涵盖了更多的基础:

  1. 将apt升级添加到您的容器中

  2. 手动安装sudo(apt-get install sudo

  3. 用于修复DOCKER容器命令的最后一个方法:RUN apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/*