I’m taking Computing Management . I have a question on assignment:

You need to create a Dockerfile, which will describe the creation of an image with the following properties:

  • When launching a container from this image without arguments, it should output the string "Hello World!" and complete the work
  • When you start the container with the argument <arg>, the string "Hello <arg>!" Should be displayed, after which the container should complete its work

An example of how the solution should work:

docker build -t test.

docker run --rm test

> Hello World!

docker run --rm test Universe

> Hello Universe!

My decision:

FROM ubuntu:14.04 LABEL maintainer="Egor Urvanov" ENTRYPOINT ["echo", "Hello"] CMD ["world!"] 

The problem is that when I run a container from an image with an argument, I can't get it out

 > Hello Universe! 

How can I fix this error.

Here you can find the job completely.

    1 answer 1

    The arguments passed can be obtained through $.

    Your working Dockerfile:

     FROM ubuntu:14.04 LABEL maintainer="Egor Urvanov" ENTRYPOINT ["echo", "Hello"] CMD $1