Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extend existing docker container?

Tags:

docker

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.

  1. Run the container and run pip install requests
  2. Append pip install requests to the dockerFile that builds this container

Is there an alternative option ? Something like creating the tensorflow/tensorflow container from a dockerFile and then installing requests on this container.

Reading How to extend an existing docker image? to accomplish this create a dockerFile with these contents ? :

FROM tensorflow/tensorflow
RUN pip install requests
like image 506
blue-sky Avatar asked Jan 24 '17 14:01

blue-sky


People also ask

Does Dockerfile have an extension?

A Dockerfile has no extension . if your using docker on docker on windows use notepad ++ to create a dockerfile while saving select “All type “ and save the file name as “Dockerfile”.

What is docker image extension?

Docker Extensions lets you use third-party tools within Docker Desktop to extend its functionality. You can seamlessly connect your favorite development tools to your application development and deployment workflows.


1 Answers

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 .

run it:

docker run -it me/mytensorflow

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

get logs from it:

docker logs `docker ps -ql`

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

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

like image 50
thoth Avatar answered Sep 19 '22 16:09

thoth