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‘
, the executable command 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
Exit with Exit or ctrl+d after interactive execution is complete
Daemonized Docker
# docker run-d Fedora/bin/sh-c "while true; do echo Hello world; Sleep 1; Done "7f22b335fb2cb2342475f720eaaf666703c97f96ea07b8a1b23e020c21a9f1a7
-d 创建一个daemon,并在后台执行命令
7f22b335fb2cb2342475f720eaaf666703c97f96ea07b8a1b23e020c21a9f1a7 container ID
can 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
Daemon information, there is Docker command, ID, status and name, the name is automatically generated.
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