如何扩展现有的Docker容器? [英] How to extend existing docker container?
问题描述
tensorflow docker容器可从 https://hub.docker.com/r/获得。 tensorflow / tensorflow / 使用其他库扩展该容器,例如请求
我知道两个选择。
The tensorflow docker container is available at https://hub.docker.com/r/tensorflow/tensorflow/ to extend this container with additional libraries such as requests
I'm aware of two options.
- 运行容器并运行
pip安装请求
- 追加
pip安装请求
到构建容器的dockerFile
- Run the container and run
pip install requests
- Append
pip install requests
to thedockerFile
that builds this container
是否有其他选择?例如,从dockerFile创建 tensorflow / tensorflow
容器,然后在该容器上安装请求
。
Is there an alternative option ? Something like creating the tensorflow/tensorflow
container from a dockerFile and then installing requests
on this container.
阅读如何扩展现有docker映像为此要创建具有这些内容的dockerFile? :
Reading How to extend an existing docker image? to accomplish this create a dockerFile with these contents ? :
FROM tensorflow/tensorflow
RUN pip install requests
推荐答案
您的原始断言正确,创建一个新的Dockerfile:
Your original assertion is correct, create a new Dockerfile:
FROM tensorflow/tensorflow
RUN pip install requests
现在构建它(请注意名称应为小写):
now build it (note that the name should be lower case):
docker build -t me/mytensorflow .
运行它:
docker run -it me/mytensorflow
在其中执行shell( docker ps -ql
为我们提供了要运行的最后一个容器的ID):
execute a shell in it (docker ps -ql
gives us an id of the last container to run):
docker exec -it `docker ps -ql` /bin/bash
从中获取日志:
docker logs `docker ps -ql`
扩展其他映像的能力使docker真正强大,此外,您还可以查看其Dockerfile:
The ability to extend other images is what makes docker really powerful, in addition you can go look at their Dockerfile:
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools / docker
并从那里开始,而不扩展其docker镜像,这是在生产环境中使用docker的人们的最佳实践,因此您知道一切都已构建在内部,而不是由一些黑客偷偷将东西偷偷带入您的基础设施。干杯!和快乐的建筑
and start from there as well without extending their docker image, this is a best practice for people using docker in production so you know everything is built in-house and not by some hacker sneaking stuff into your infrastructure. Cheers! and happy building
这篇关于如何扩展现有的Docker容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!