Code Monkey home page Code Monkey logo

Comments (3)

buchs avatar buchs commented on June 4, 2024

Re: docker/docs#580 (comment)

from cli.

adeniyistephen avatar adeniyistephen commented on June 4, 2024

@thaJeztah Hi, I would love to work on this, Please provide pointers and input on how to work on it. Thanks

from cli.

thaJeztah avatar thaJeztah commented on June 4, 2024

The example given works for setting one Env environment variable, though it seems to be additive only.

Yes, it's following the same rules as a Dockerfile, which currently doesn't support unsetting properties (see moby/moby#3465).

Can one set multiple Env variables?

Yes, it's possible to set multiple env-vars.

For ENV, it's possible to combine multiple environments in a single ENV (again, following the same syntax as the Dockerfile ENV syntax);

docker commit --change 'ENV FOO=bar OTHER_ENV=other-value' mycontainer myimage:latest

Or specifying multiple --change flags;

docker commit \
    --change 'ENV FOO=bar'\
    --change 'ENV OTHER_ENV=other-value' \
    --change 'LABEL hello=world' \
    mycontainer myimage:latest

Can one delete an Env variable? Can one completely overwrite all of Env?

No, that's not possible (see my first comment above)

In addition, another syntax seems to work that includes square brackets

Some Dockerfile instructions support a JSON-array syntax, such as the ENTRYPOINT instruction; https://docs.docker.com/engine/reference/builder/#entrypoint

This syntax could be elaborated upon

I don't think we should elaborate on the syntax itself as part of the docker commit reference documentation, but given that it already mentions the Dockerfile syntax, a link to the Dockerfile syntax (https://docs.docker.com/engine/reference/builder/) could be included.

unless using it is not best practice.

As to "JSON-array" ("exec") versus "shell" syntax; some of the (dis)advantages of each are explained in the Dockerfile syntax reference, so I don't think that should be repeated for this command specifically.

As to "best practice" on using docker commit --change; I would consider docker commit --change mostly for debugging purposes (for example, to update a failed container's command for debugging).

I would definitely not recommend using docker run followed by docker commit to build an image as a recommended workflow; for that, using a Dockerfile is definitely the recommended approach, as this allows the Dockerfile to describe how the image is built, and allows one to repeat the same build to produce the image.

from cli.

Related Issues (20)

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.