Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Hello world with Dockerizing

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to achieve Hello world in Dockerizing". In daily operation, I believe many people have doubts about how to achieve Hello world in Dockerizing. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to achieve Hello world in Dockerizing". Next, please follow the editor to study!

/ / download ubuntu:14.04

Luoo@PS:~$ docker pull ubuntu:14.04

Fa4fd76b09ce: Pull complete

Fa4fd76b09ce: Download complete

1c8294cc5160: Download complete

117ee323aaa9: Download complete

2d24f826cb16: Download complete

511136ea3c5a: Download complete

Status: Downloaded newer image for ubuntu:14.04

/ / run echo 'Hello world'

Luoo@PS:~$ docker run ubuntu:14.04 bin/echo 'Hello world'

Hello world

/ / enter the interactive environment of the container.-t opens a terminal in the container, and-I enters the interactive environment.

Luoo@PS:~$ docker run-t-I ubuntu:14.04 / bin/bash

Root@61684a876af5:/#

Root@61684a876af5:/# pwd

/

Root@61684a876af5:/# ls

Bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var

Root@61684a876af5:/# exit

Exit

A Daemonized (daemon) Hello world

/ /-d tell the container to run the task in the background

Luoo@PS:~$ docker run-d ubuntu:14.04 / bin/sh-c "while true; do echo hello world; sleep 1; done"

Dc34a2103c84cc0f859f96d2a865aad85f4302c9f1056f8b4e33fbaeed5b6129

/ / View the running container

Luoo@PS:~$ docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

Dc34a2103c84 ubuntu:14.04 "/ bin/sh-c 'while t About a minute ago Up About a minute goofy_sinoussi

/ / View the output of the specified container dc34a2103c84

Luoo@PS:~$ docker logs dc34a2103c84

Hello world

Hello world

Hello world

Hello world

Hello world

Hello world

/ / stop the container dc34a2103c84 from running

Luoo@PS:~$ docker stop dc34a2103c84

Dc34a2103c84

/ / View the running container

Luoo@PS:~$ docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

At this point, the study on "how to achieve Hello world in Dockerizing" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report