Docker simple use of commands

Source: Internet
Author: User
Tags docker run

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#

-tIn container, assign a terminal

-iCreate 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 logsView the normalized output of the daemon by command

# Docker logs Silly_archimedeshello Worldhello Worldhello world ...

docker stopStop 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.