Dockerfile with ENTRYPOINT
Let’s rebuild the get-time
image using an ENTRYPOINT
.
FROM debian
COPY get-time.sh /usr/local/bin
RUN chmod +x /usr/local/bin/get-time.sh
ENTRYPOINT [ "/usr/local/bin/get-time.sh" ]
Rebuild the Docker image.
docker build -f Dockerfile.using_entrypoint -t get-time .
Now run a container.
docker run -it --rm --name timectr get-time
Fetch UTC(NIST) time every 5 seconds...
21-09-02 19:30:53
^C
So far the behavior seems the same. However, unlike with CMD
, arguments
don’t override the ENTRYPOINT
; instead, they are passed to. This behavior is
more aligned with our expectations for containers that run specific programs.
docker run -it --rm --name timectr get-time 2
Fetch UTC(NIST) time every 2 seconds...
21-09-02 19:33:26
21-09-02 19:33:28
^C
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.