beginners/dockerfile/Dockerfile-ENTRYPOINT.md
The ENTRYPOINT instruction make your container run as an executable.
ENTRYPOINT can be configured in two forms:
<b> Exec Form </b>
ENTRYPOINT ["executable", "param1", "param2"]
<b>Shell Form</b>
ENTRYPOINT command param1 param2
If an image has an ENTRYPOINT if you pass an argument it, while running container it wont override the existing entrypoint, it will append what you passed with the entrypoint.To override the existing ENTRYPOINT you should user <b>--entrypoint</b> flag when running container.
Dockerfile
FROM alpine:3.5
LABEL maintainer="Collabnix"
ENTRYPOINT ["/bin/echo", "Hi, your ENTRYPOINT instruction in Exec Form !"]
$ docker build -t entrypoint:v1 .
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
entrypoint v1 1d06f06c2062 2 minutes ago 4MB
alpine 3.5 f80194ae2e0c 7 months ago 4MB
$ docker container run entrypoint:v1
Hi, your ENTRYPOINT instruction in Exec Form !
Dockerfile
$ cat Dockerfile
FROM alpine:3.5
LABEL maintainer="Collabnix"
ENTRYPOINT echo "Hi, your ENTRYPOINT instruction in Shell Form !"
$ docker build -t entrypoint:v2 .
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
entrypoint v2 cde521f13080 2 minutes ago 4MB
entrypoint v1 1d06f06c2062 5 minutes ago 4MB
alpine 3.5 f80194ae2e0c 7 months ago 4MB
$ docker container run entrypoint:v2
Hi, your ENTRYPOINT instruction in Shell Form !
$ docker container run --entrypoint "/bin/echo" entrypoint:v2 "Hello, Welcome to Docker Meetup! "
Hello, Welcome to Docker Meetup!