如何在 docker 镜像中安装 python?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47216784/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install python in a docker image?
提问by Alex
I want to create a docker image with selenium
and chrome
correctly installed, so I choose a base image with these properties. Therefore, the first line of the Dockerfile
is as follows:
我想创建一个码头工人形象与selenium
和chrome
正确安装,所以我选择具有这些特性的基础图像。因此,第一行Dockerfile
如下:
FROM selenium/node-chrome:3.7.1-argon
Then the next command is
然后下一个命令是
RUN apt-get update
which created the following error while creating the docker image:
在创建 docker 镜像时产生了以下错误:
Step 4/19 : RUN apt-get update
---> Running in af08ae07cbf3
Reading package lists...
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)
The command '/bin/sh -c apt-get update' returned a non-zero code: 100
How to be able to install python
in this docker image?
如何能够python
在这个 docker 镜像中安装?
采纳答案by mikey
RUN sudo apt-get update
RUN sudo apt-get update
RUN sudo apt-get install python
RUN sudo apt-get install python
As hinted by:
正如所暗示的:
Acquire (13: Permission denied)
获取(13:权限被拒绝)
I believe this is due to your base image:
我相信这是由于您的基本图像:
https://github.com/SeleniumHQ/docker-selenium/blob/master/NodeChrome/Dockerfile
https://github.com/SeleniumHQ/docker-selenium/blob/master/NodeChrome/Dockerfile
As you can see it swaps from the default user context of 'root' to 'seluser'.
如您所见,它从“root”的默认用户上下文切换到“seluser”。
You can either:
您可以:
- wear this as a consequence of the base image (i.e. use sudo)
- swap back:
USER root
- or consider creating your own docker image to avoid swapping in the first place
- 作为基础图像的结果佩戴它(即使用 sudo)
- 换回:
USER root
- 或者考虑创建自己的 docker 镜像以避免首先交换
Hope that helps mate.
希望能帮到朋友。