When ever we want a command will run after every time container will start then use ENTRYPOINT
[root@ip-172-31-82-31 dockerfiles]# vi Dockerfile
[root@ip-172-31-82-31 dockerfiles]# cat Dockerfile
FROM ubuntu:16.04
ENV NAME raj
ENV PASS password123
RUN mkdir -p /var/run/sshd
RUN apt-get update
RUN apt-get install -y python tree
ENTRYPOINT [ "tree" ]
[root@ip-172-31-82-31 dockerfiles]#
[root@ip-172-31-82-31 dockerfiles]# vi Dockerfile
[root@ip-172-31-82-31 dockerfiles]# cat Dockerfile
FROM ubuntu:16.04
ENV NAME raj
ENV PASS password123
RUN mkdir -p /var/run/sshd
RUN apt-get update
RUN apt-get install -y python tree
ENTRYPOINT [ "tree" ]
[root@ip-172-31-82-31 dockerfiles]#
[root@ip-172-31-82-31 dockerfiles]# docker image build -t rajubuntu:85 .
[root@ip-172-31-82-31 dockerfiles]# docker container run -P -itd rajubuntu:85
when you want output of particular command like tree its version only every time
[root@ip-172-31-82-31 dockerfiles]# cat Dockerfile
FROM ubuntu:16.04
ENV NAME raj
ENV PASS password123
RUN mkdir -p /var/run/sshd
RUN apt-get update
RUN apt-get install -y python tree
ENTRYPOINT [ "tree" ]
CMD ["--version"]
[root@ip-172-31-82-31 dockerfiles]# docker image build -t rajubuntu:90 .
[root@ip-172-31-82-31 dockerfiles]# docker container run -P -it rajubuntu:90
tree v1.7.0 (c) 1996 - 2014 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro
[root@ip-172-31-82-31 dockerfiles]#
No comments:
Post a Comment