Debug School

Posted on

USING 2 ENTRYPOINT Commands in dockerfile

When you use 2 entrypoint commands the last entrypoint command will be considered.

  1. Write docekrfile with 2 entrypoint commands:
    FROM ubuntu
    MAINTAINER Rajesh Kumar <<>>
    ENV DEBIAN_FRONTEND=noninteractive
    RUN apt-get update
    RUN apt-get -y install tzdata
    RUN apt-get install git -y && apt-get install -yq apache2
    CMD echo "Hello world"
    ENTRYPOINT ["/bin/echo", "Hello"]
    ENTRYPOINT ["ls"]

  2. Build the docker image using docker file

[root@localhost docs]# docker build -t aswin10 -f doc7 .
Sending build context to Docker daemon 9.728kB
Step 1/9 : FROM ubuntu
---> a8780b506fa4
Step 2/9 : MAINTAINER Rajesh Kumar <<>>
---> Using cache
---> 88f6b6acfa81
Step 3/9 : ENV DEBIAN_FRONTEND=noninteractive
---> Using cache
---> c8a76e7a5f98
Step 4/9 : RUN apt-get update
---> Using cache
---> 4d9fe31bf152
Step 5/9 : RUN apt-get -y install tzdata
---> Using cache
---> 41891c047aab
Step 6/9 : RUN apt-get install git -y && apt-get install -yq apache2
---> Using cache
---> cfaefb036054
Step 7/9 : CMD echo "Hello world"
---> Using cache
---> e3a33016f8d3
Step 8/9 : ENTRYPOINT ["/bin/echo", "Hello"]
---> Using cache
---> a2eacdc1de3e
Step 9/9 : ENTRYPOINT ["ls"]
---> Running in 12768c86a79f
Removing intermediate container 12768c86a79f
---> 376e50f8e2e0
Successfully built 376e50f8e2e0
Successfully tagged aswin10:latest
[root@localhost docs]# docker images
aswin10 latest 376e50f8e2e0 11 seconds ago 252MB

  1. Creating the container using the run command: [root@localhost docs]# docker run -itd aswin10 e908ee7c1647d28048b5bb693e6c590b671ea93d72968cad4c15445e2bcda108 [root@localhost docs]# docekr ps -a bash: docekr: command not found... Similar command is: 'docker' [root@localhost docs]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e908ee7c1647 aswin10 "ls /bin/sh -c 'echo…" 8 seconds ago Exited (2) 7 seconds ago eager_torvalds

Top comments (0)