lij*_*050 1 pip amazon-web-services python-2.7 docker
我在 docker 中安装了一个名为 requests-aws4auth 的 python 模块,使用RUN pip install requests-aws4auth
现在我想通过进入cd /opt/conda/lib/python2.7/site-packages/requests_aws4auth/并注释aws4auth.py文件中的一行来修改它。我在构建 docker 时已经安装了 vim。
是否可以在构建 dockerfile 时执行此操作?如果是的话,有人可以帮助我吗?
我可以通过使用sudo docker run -i -t image_name /bin/bash和修改文件来做到这一点,但这将创建一个容器。现在,有什么办法可以将容器推回镜像吗?
有两种方法可以做到这一点:
添加一些 sed 命令,在 dockerfile 中的命令之后注释文件中的行,pip install如下所示 -
RUN pip install requests-aws4auth
RUN sed -e '/BBB/ s/^#*/#/' -i file #some logic to comment the line
构建 docker 映像并使用它。
如果选项 1 似乎没有帮助,请尝试提交容器。
docker run容器执行docker exec并注释文件中的行。现在提交容器docker commit <conatainer-id> <some custom image name> https://docs.docker.com/engine/reference/commandline/commit/
现在使用此自定义映像。
| 归档时间: |
|
| 查看次数: |
785 次 |
| 最近记录: |