Hello World
Use[docker run
]命令在docker container中执行应用程序
<pre name= "code" class= "plain" ># Docker run Fedora/bin/echo ' Hello World ' Hello World
docker run fedora
, use the image of fedora to start a container
/bin/echo ‘hello world‘
, a command that can be run in fedora, output "Hello World"
Interactive container
# docker Run-t-I fedora/bin/bashbash-4.3#
-t
In container, assign a terminal
-i
Create an interactive connection
When the interaction is complete, exit with exit or Ctrl+d
Daemonized Docker
# docker run-d Fedora/bin/sh-c "while true; do echo Hello world; Sleep 1; Done "7f22b335fb2cb2342475f720eaaf666703c97f96ea07b8a1b23e020c21a9f1a7
-d 创建一个daemon,并在后台运行命令
7f22b335fb2cb2342475f720eaaf666703c97f96ea07b8a1b23e020c21a9f1a7 container ID
be able to usedocker ps查看docker daemon信息
# docker Pscontainer ID IMAGE COMMAND CREATED STATUS PORTS names7f22b335fb2c Fedora: Latest "/bin/sh-c" while T 5 minutes ago up 5 minutes Silly_archimedes
In the daemon information, there are Docker commands, IDs, states and names, and the names are generated on their own initiative.
docker logs
View the normalized output of the daemon by command
# Docker logs Silly_archimedeshello Worldhello Worldhello world ...
docker stop
Stop the specified Docker daemon by command
# Docker Stop Silly_archimedessilly_archimedes
View Docker Daemon again
# docker Pscontainer ID IMAGE COMMAND CREATED STATUS PORTS NAMES
There's no previous Docker daemon.
Docker simple use of commands