How to extend existing docker container?

后端 未结 2 2047
余生分开走
余生分开走 2020-12-16 15:05

The tensorflow docker container is available at https://hub.docker.com/r/tensorflow/tensorflow/ to extend this container with additional libraries such as requests

相关标签:
2条回答
  • 2020-12-16 15:21

    you could enter the running container via:

    docker exec -it CONTAINER_ID bin/bash
    

    or if a name is set:

    docker exec -it CONTAINER_NAME bin/bash
    
    0 讨论(0)
  • 2020-12-16 15:33

    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

    0 讨论(0)
提交回复
热议问题