我使用 RUN pip install requests-aws4auth
在 docker 中安装了一个名为 requests-aws4auth 的 Python 模块
现在我想通过进入 cd /opt/conda/lib/python2.7/site-packages/requests_aws4auth/
来修改它并在 aws4auth.py
中评论一行文件。我在构建 docker 时已经安装了 vim。
在构建 dockerfile 时是否可以这样做?如果是,那么有人可以帮助我。
我可以使用 sudo docker run -i -t image_name /bin/bash
并修改文件,但这将创建一个容器。现在,有没有办法将容器推回图像。
最佳答案
有两种方法可以做到这一 pip :
pip install
之后的行dockerfile 中的命令是这样的 -
RUN pip install requests-aws4auth
RUN sed -e '/BBB/ s/^#*/#/' -i file #some logic to comment the line
构建 docker 镜像并使用它。 docker run
容器做docker exec
并注释文件中的行。现在提交容器 docker commit <conatainer-id> <some custom image name>
https://docs.docker.com/engine/reference/commandline/commit/现在使用这个自定义图像。
关于python-2.7 - 修改在 Docker 镜像中使用 pip 安装的 python 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47647270/