Giter Site home page Giter Site logo

Comments (4)

yosifkit avatar yosifkit commented on August 12, 2024

We have been standardizing CMD for the default command for all official base images. It is easier to override (docker run -it nginx bash vs docker run -it --entrypoint=/bin/bash nginx -i). It can throw off a user if they say bash and still get nginx running or just an error. We have been using entrypoint for start scripts that need access to possibly mounted volumes (see docker-library/postgres). We are still working to fully document the styles and guidelines of Official Images.

from nginx.

yankeeinlondon avatar yankeeinlondon commented on August 12, 2024

I thought it was accepted conventional wisdom to use ENTRYPOINT? In 99% of cases you'd want to just provide nginx switches as options to the run right? Using ENTRYPOINT you get:

# show configuration options
sudo docker run nginx:1.x -v
# send signalling to nginx:1.x
sudo docker run nginx:1.x -s reload

This feels very natural an mimics the signature of a bare-metal implementation. In comparison, the CMD approach requires the awkward double nginx reference:

# show configuration options
sudo docker run nginx:1.x nginx -v
# send signalling to nginx:1.x
sudo docker run nginx:1.x nginx -s reload

Furthermore, if the use cases you're looking to make easier are getting inside a running container then you'd still really need something like nsenter/nsinit wouldn't you? To get an interactive session with the nginx image then the --entrypoint example makes sense but this is I think less common and if people find themselves needing to do this with their images then creating a simple Bash shortcut like:

function into () {
    if [[ -z "$1" ]]; then
        echo "Usage:"
        echo "   into [image-id]"
        echo ""
        echo "Current Images: [sudo docker images]"
        echo ""
        sudo docker images
    else
        echo "Jumping into Docker Image:"
        echo "  - sudo docker run -it --entrypoint=\"/bin/bash\" \"$1\""
        sudo docker run -it --entrypoint="/bin/bash" "$1"
    fi
}

Similarly I have done the same thing with jumping into running containers (which I find generally more useful):

function container () {
    if [[ -z "$1" ]];then
        echo "You must supply the container-id (or name)"
    else
        PID=`sudo docker inspect --format "{{ .State.Pid }}" $1`
        echo "Process ID is "$PID
        sudo nsenter --target "$PID" --mount --uts --ipc --net --pid
    fi
}

from nginx.

yosifkit avatar yosifkit commented on August 12, 2024

So, in order to make it simpler for starting users, official images will not be using entrypoint instead of cmd. Refs: best practices#cmd, best practices#entrypoint.

Nginx upstream will now be providing and maintaining the images nginxinc/docker-nginx.

from nginx.

anapsix avatar anapsix commented on August 12, 2024

moved my rant to docker-library/official-images#692

from nginx.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.