ubuntuimage, but installs the Apache web server and your application, as well as the configuration details needed to make your application run.
docker runcommands, the required images are pulled from your configured registry. When you use the
docker pushcommand, your image is pushed to your configured registry.
docker run hello-worldcommand.
image namecan be any image from Docker Hub or our local machine. I hope that you've noticed that I've been saying create and run and not just run, the reason behind that is the docker run command actually does the job of two separate docker commands. They are:
docker create <image name>creates a container from given image and returns the container id.
docker start <image name>starts a container by given id of a already created command.
c41d97e867380b372f56d4801e9e83b2b528da17792c390b4825bbb2289f9bcfThis id can be used to start the built container.
docker pscommand :
--alloption indicates that we want to see not only the running containers but also the stopped ones. Executing ps without the -a option will list out the running containers only.
startcommand to run a container. There is another command for starting containers called
restart. Though the commands seem to serve the same purpose on the surface, they have a slight difference.
startcommand starts containers that are not running. The
restartcommand, however, kills a running container and starts that again. If we use restart with a stopped container then it'll function just as same as the start command.
rmcommand. Generic syntax for this command is as follows:
docker run ubuntucommand, we'll see nothing happens. But if we execute the command with
-itoption as follows:
-itoption is that the Ubuntu image is configured to start bash upon startup. Bash is an interactive program – that means if we do not type in any commands, bash won't do anything.
-itoption sets the stage for us to interact with any interactive program inside a container. This option is actually two separate options mashed together.
-ioption connects us to the input stream of the container, so that we can send inputs to bash.
-toption makes sure that we get some good formatting and a native terminal like experience.
--detachoption. To run the container in detached mode, execute the following command:
docker stop <container id>attempts to stop the container gracefully by sending a SIGTERM signal to the container. If the container doesn't stop within a grace period, a SIGKILL signal is sent.
docker kill <container id>stops the container immediately by sending a SIGKILL signal. A SIGKILL signal can not be ignored by a recipient.
bb7fadc33178execute docker stop
docker kill bb7fadc33178will terminate the container immediately without giving a chance to clean up.
logscommand to retrieve logs from a running container. The generic syntax for the command is as follows:
970f1a18714a ,in order to access the logs from the container:
--followoption and Any later log will show up instantly in the terminal. We can exit by pressing
ctrl+ckey combination or simply closing the window. The container will keep running even if you exit out of the log window.