1

If I have a super-dumb dockerfile, like this:

FROM ubuntu:latest ENTRYPOINT echo 

Is it possible to pass arguments to the ENTRYPOINT, so that it will print whatever argument I pass? I tried docker build -t test . && docker run test foo but I just got an empty line.

4
  • I would recommend a combination of arguments and/or environment variables, as this SO answer outlines. You can specify default values if you like. Your ENTRYPOINT line should allow you to make use of an env var. Commented Jan 30, 2018 at 16:11
  • Is it possible to directly do the thing I'm asking about, or do I need to use a different solution? Commented Jan 30, 2018 at 16:12
  • I don't own the Dockerfile in question Commented Jan 30, 2018 at 16:12
  • 1
    If you can't edit the Dockerfile, you may wish to build a new Dockerfile off of the original one; assuming it's build specific. Otherwise you next best option may be to override the entrypoint during your docker run, such as docker run --entrypoint="<your new entrypoint>". Here's the documentation from Docker. Commented Jan 30, 2018 at 16:15

1 Answer 1

1

You can extend the image and fix the entrypoint:

FROM user_name/image_name ENTRYPOINT ["echo"] 

Or override the entrypoint:

docker run --entrypoint=echo user_name/image_name Hello World 

Either way you don't need to be the owner of the Dockerfile you mention as long as you have access to the image.

Sign up to request clarification or add additional context in comments.

2 Comments

I don't own the dockerfile. I'm trying to find a way to do it from the command line
Either extend the image or override the entrypoint via arguments of docker run then.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.