I have a query regarding the execution of commands in a container from the Dockerfile.
#Dockerfile Content: FROM ubuntu:14.04 MAINTAINER RAGHU RUN echo "hello World" Build procedure
docker build -t helloworld . Sending build context to Docker daemon 20.04 MB Step 1 : FROM ubuntu:14.04 ---> b1719e1db756 Step 2 : MAINTAINER RAGHU ---> Using cache ---> 1704b62d66e2 Step 3 : RUN echo "hello World" ---> Running in 2b513872628e hello World ---> ff559047fd19 Removing intermediate container 2b513872628e Successfully built ff559047fd19 Query 1: Why does the below execution has not resulted in any result ? I am expecting to print "hello World". What wrong has happened ?
root@labadmin-VirtualBox:/home/labadmin# docker run ff559047fd19 root@labadmin-VirtualBox:/home/labadmin# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a8eede1874a2 ff559047fd19 "/bin/bash" 27 seconds ago Exited (0) 26 seconds ago tiny_williams root@labadmin-VirtualBox:/home/labadmin# docker logs a8eede1874a2 #Above command has not resulted in any logs for this container. Query 2 :I am able to run the execution steps in the following way. Why it has executed the command in the below container and why not when I run the container a8eede1874a2 ?
root@labadmin-VirtualBox:/home/labadmin# docker run -it ff559047fd19 root@486595ac9110:/# echo "hello world" hello world root@486595ac9110:/# exit exit root@labadmin-VirtualBox:/home/labadmin/RAGHU/welcome-page# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 486595ac9110 ff559047fd19 "/bin/bash" 22 seconds ago Exited (0) 7 seconds ago goofy_noyce a8eede1874a2 ff559047fd19 "/bin/bash" About a minute ago Exited (0) About a minute ago tiny_williams root@labadmin-VirtualBox:/home/labadmin# docker logs 486595ac9110 root@486595ac9110:/# echo "hello world" hello world root@486595ac9110:/# exit exit root@labadmin-VirtualBox:/home/labadmin/RAGHU/welcome-page#