Run a simple application

systemd服务配置:simple与forking类型详解及实战排错指南 在Linux系统服务管理中,进程生命周期管理是核心基础概念。systemd作为现代初始化系统,通过服务单元文件定义进程的启动、监控和管理方式。其核心原理在于systemd需要明确识别哪个进程是服务的主进程,以便进行状态跟踪和资源控制。这一机制的技术价值在于实现了服务的可靠启动、状态精确监控和自动化运维。在应用场景上,传统后台守护进程和现代前台应用需要不同的管理协议。本文聚焦于systemd中simple与forking两种常用服务类型,深入解析其差异。通过分析服务启动失败等常见问题,特别是结合systemd 阅读详情

Run a simple application

In the “Hello world in a container“ you launched yourfirst containers using the docker run command. You ran an interactive container that ran in the foreground. You also ran a detached container that ran in the background. In the process you learned about several Docker commands:

  • docker ps - Lists containers.
  • docker logs - Shows us the standard output of a container.
  • docker stop - Stops running containers.

Learn about the Docker client

If you didn’t realize it yet, you’ve been using the Docker client each time youtyped docker in your Bash terminal. The client is a simple command line clientalso known as a command-line interface (CLI). Each action you can take withthe client is a command and each command can take a series of flags and arguments.

# Usage:  [sudo] docker [subcommand] [flags] [arguments] ..
# Example:
$ docker run -i -t ubuntu /bin/bash

You can see this in action by using the docker version command to returnversion information on the currently installed Docker client and daemon.

$ docker version

This command will not only provide you the version of Docker client anddaemon you are using, but also the version of Go (the programminglanguage powering Docker).

Client:
  Version:      1.8.1
  API version:  1.20
  Go version:   go1.4.2
  Git commit:   d12ea79
  Built:        Thu Aug 13 02:35:49 UTC 2015
  OS/Arch:      linux/amd64

Server:
  Version:      1.8.1
  API version:  1.20
  Go version:   go1.4.2
  Git commit:   d12ea79
  Built:        Thu Aug 13 02:35:49 UTC 2015
  OS/Arch:      linux/amd64

Get Docker command help

You can display the help for specific Docker commands. The help details theoptions and their usage. To see a list of all the possible commands, use thefollowing:

$ docker --help

To see usage for a specific command, specify the command with the --help flag:

$ docker attach --help

Usage: docker attach [OPTIONS] CONTAINER

Attach to a running container

  --help=false        Print usage
  --no-stdin=false    Do not attach stdin
  --sig-proxy=true    Proxy all received signals to the process

Note:For further details and examples of each command, see thecommand reference in this guide.

Running a web application in Docker

So now you’ve learned a bit more about the docker client you can move ontothe important stuff: running more containers. So far none of thecontainers you’ve run did anything particularly useful, so you canchange that by running an example web application in Docker.

For our web application we’re going to run a Python Flask application.Start with a docker run command.

$ docker run -d -P training/webapp python app.py

Review what the command did. You’ve specified two flags: -d and-P. You’ve already seen the -d flag which tells Docker to run thecontainer in the background. The -P flag is new and tells Docker tomap any required network ports inside our container to our host. Thislets us view our web application.

You’ve specified an image: training/webapp. This image is apre-built image you’ve created that contains a simple Python Flask webapplication.

Lastly, you’ve specified a command for our container to run: python app.py. This launches our web application.

Note:You can see more detail on the docker run command in the commandreference and the Docker RunReference.

Viewing our web application container

Now you can see your running container using the docker ps command.

$ docker ps -l
CONTAINER ID  IMAGE                   COMMAND       CREATED        STATUS        PORTS                    NAMES
bc533791f3f5  training/webapp:latest  python app.py 5 seconds ago  Up 2 seconds  0.0.0.0:49155->5000/tcp  nostalgic_morse

You can see you’ve specified a new flag, -l, for the docker pscommand. This tells the docker ps command to return the details of thelast container started.

Note:By default, the docker ps command only shows information about runningcontainers. If you want to see stopped containers too use the -a flag.

We can see the same details we saw when we first Dockerized acontainer with one important addition in the PORTScolumn.

PORTS
0.0.0.0:49155->5000/tcp

When we passed the -P flag to the docker run command Docker mapped anyports exposed in our image to our host.

Note:We’ll learn more about how to expose ports in Docker images whenwe learn how to build images.

In this case Docker has exposed port 5000 (the default Python Flaskport) on port 49155.

Network port bindings are very configurable in Docker. In our last example the-P flag is a shortcut for -p 5000 that maps port 5000 inside the containerto a high port (from ephemeral port range which typically ranges from 32768to 61000) on the local Docker host. We can also bind Docker containers tospecific ports using the -p flag, for example:

$ docker run -d -p 80:5000 training/webapp python app.py

This would map port 5000 inside our container to port 80 on our localhost. You might be asking about now: why wouldn’t we just want to alwaysuse 1:1 port mappings in Docker containers rather than mapping to highports? Well 1:1 mappings have the constraint of only being able to mapone of each port on your local host.

Suppose you want to test two Python applications: both bound to port 5000 insidetheir own containers. Without Docker’s port mapping you could only access one ata time on the Docker host.

So you can now browse to port 49155 in a web browser tosee the application.

Viewing the web application.

Our Python application is live!

Note:If you have been using a virtual machine on OS X, Windows or Linux,you’ll need to get the IP of the virtual host instead of using localhost.You can do this by running the docker-machine ip your_vm_name from your command line or terminal application, for example:

$ docker-machine ip my-docker-vm
192.168.99.100

In this case you’d browse to http://192.168.99.100:49155 for the above example.

A network port shortcut

Using the docker ps command to return the mapped port is a bit clumsy soDocker has a useful shortcut we can use: docker port. To use docker port wespecify the ID or name of our container and then the port for which we need thecorresponding public-facing port.

$ docker port nostalgic_morse 5000
0.0.0.0:49155

In this case you’ve looked up what port is mapped externally to port 5000 insidethe container.

Viewing the web application’s logs

You can also find out a bit more about what’s happening with our application anduse another of the commands you’ve learned, docker logs.

$ docker logs -f nostalgic_morse
* Running on http://0.0.0.0:5000/
10.0.2.2 - - [23/May/2014 20:16:31] "GET / HTTP/1.1" 200 -
10.0.2.2 - - [23/May/2014 20:16:31] "GET /favicon.ico HTTP/1.1" 404 -

This time though you’ve added a new flag, -f. This causes the dockerlogs command to act like the tail -f command and watch thecontainer’s standard out. We can see here the logs from Flask showingthe application running on port 5000 and the access log entries for it.

Looking at our web application container’s processes

In addition to the container’s logs we can also examine the processesrunning inside it using the docker top command.

$ docker top nostalgic_morse
PID                 USER                COMMAND
854                 root                python app.py

Here we can see our python app.py command is the only process running insidethe container.

Inspecting our web application container

Lastly, we can take a low-level dive into our Docker container using thedocker inspect command. It returns a JSON document containing usefulconfiguration and status information for the specified container.

$ docker inspect nostalgic_morse

You can see a sample of that JSON output.

[{
    "ID": "bc533791f3f500b280a9626688bc79e342e3ea0d528efe3a86a51ecb28ea20",
    "Created": "2014-05-26T05:52:40.808952951Z",
    "Path": "python",
    "Args": [
       "app.py"
    ],
    "Config": {
       "Hostname": "bc533791f3f5",
       "Domainname": "",
       "User": "",
. . .

We can also narrow down the information we want to return by requesting aspecific element, for example to return the container’s IP address we would:

$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nostalgic_morse
172.17.0.5

Stopping our web application container

Okay you’ve seen web application working. Now you can stop it using thedocker stop command and the name of our container: nostalgic_morse.

$ docker stop nostalgic_morse
nostalgic_morse

We can now use the docker ps command to check if the container hasbeen stopped.

$ docker ps -l

Restarting our web application container

Oops! Just after you stopped the container you get a call to say anotherdeveloper needs the container back. From here you have two choices: youcan create a new container or restart the old one. Look atstarting your previous container back up.

$ docker start nostalgic_morse
nostalgic_morse

Now quickly run docker ps -l again to see the running container isback up or browse to the container’s URL to see if the applicationresponds.

Note:Also available is the docker restart command that runs a stop andthen start on the container.

Removing our web application container

Your colleague has let you know that they’ve now finished with the containerand won’t need it again. Now, you can remove it using the docker rm command.

$ docker rm nostalgic_morse
Error: Impossible to remove a running container, please stop it first or use -f
2014/05/24 08:12:56 Error: failed to remove one or more containers

What happened? We can’t actually remove a running container. This protectsyou from accidentally removing a running container you might need. You can trythis again by stopping the container first.

$ docker stop nostalgic_morse
nostalgic_morse
$ docker rm nostalgic_morse
nostalgic_morse

And now our container is stopped and deleted.

Note:Always remember that removing a container is final!

Next steps

Until now you’ve only used images that you’ve downloaded from Docker Hub. Next,you can get introduced to building and sharing our own images.

Go to Working with Docker Images.

高速DAC设计与实现--AD9122 目录 芯片简介: 功能配置设计 高速DAC软件驱动设计 芯片简介: AD9122 是一款双通道16位高性能数模转换器(DAC),在800MSPS工作条件下其无杂散动态范围(SFDR)高达72dBc,最高可提供1200 MSPS采样速率。 高速DAC--AD9122电路原理图 硬件设计的电路原理图如上图所示,AD9122具备针对直接变频传输应用进行优化的特性,包括复数数字调制以及增益与失调补偿。DAC输出经过优化后可直接与模拟正交调制器无缝接口,便于后期使... 阅读详情

相关推荐

iStore增强插件 如何重塑家庭网络与存储体验

本文深入解析了iStore增强插件如何重塑家庭数字生活体验。它通过集成智能流控、一键式文件共享、媒体服务器及智能家居网关等功能,将复杂的网络配置、存储管理与设备协同简化为图形化操作,有效解决了家庭网络卡顿、数据割裂与使用门槛高等核心痛点,让普通用户也能轻松打造高效、稳定、安全的家庭数字中枢。

prometheus9mon的博客 646

Windows 10 docker

环境配置

weixin_56049214的博客 3400

CHI里的Error handling机制

本文讲解了CHI里的Error handling机制。

W1Z1Q的专栏 2500

windows10安装docker desktop

【前言】 Docker在win10下安装需要专业版(pro),而目前多数个人电脑都是家庭版,所以可以基于下面的方法在家庭版上安装Docker。 1、开启Hyper-V 新建txt文件并将后缀改为.cmd,里面的内容如下: pushd "%~dp0" dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') d

zhoudatianchai的专栏 2026

RK3588上从零部署Facenet人脸识别:PyTorch转ONNX再到RKNN的完整避坑指南

本文提供了在RK3588开发板上从零部署Facenet人脸识别模型的完整指南。详细介绍了从PyTorch模型导出、转换为ONNX格式,再通过RKNN-Toolkit2转换为RKNN格式的完整流程,并重点分享了环境配置、算子兼容性处理、量化调优及板端部署中的关键步骤与避坑经验。

river的博客 462

宇树机器人G1二次开发:语音对话、打断与激活功能实现指南

宇树机器人G1是一款功能强大的四足机器人,其开放的SDK和API为开发者提供了广阔的二次开发空间。其中,语音交互是提升机器人智能化水平和用户体验的关键功能。本文将详细介绍如何在宇树机器人G1上进行二次开发,实现。语音打断允许用户在机器人说话时随时中断并输入新指令,这是提升交互自然度的关键功能。三大核心功能,帮助你构建更自然、更智能的人机交互系统。语音识别是将用户的语音输入转换为文本的过程。识别文本后,需要理解用户意图并生成回复。将文本回复转换为语音输出。

m0_52645558的博客 660

[转载] Docker网络原则入门:EXPOSE,-p,-P,-link

原文:http://dockone.io/article/455 如果你已经构建了一些多容器的应用程序,那么肯定需要定义一些网络规则来设置容器间的通信。有多种方式可以实现:可以通过--expose参数在运行时暴露端口,或者在Dockerfile里使用EXPOSE指令。还可以在Docker run的时候通过-p或者-P参数来发布端口。或者通过--link链接容器。虽然这些方式几乎都能达...

weixin_30393907的博客 1249

移远EC800M CAT1模块HTTP POST实战:从AT指令到数据上报的完整避坑指南

本文详细介绍了移远EC800M CAT1模块通过AT指令实现HTTP POST数据上报的完整开发流程,包括模块初始化、PDP上下文配置、HTTP POST实现及优化策略。针对实际开发中的常见问题如网络异常、低功耗需求等提供了经过验证的解决方案,帮助开发者快速实现稳定可靠的物联网数据传输功能。

weixin_42556197的博客 479

Docker中的“公开”和“发布”有什么区别?

I'm experimenting with Dockerfiles, and I think I understand most of the logic. 我正在试验Dockerfile,我想我

asdfgh0077的博客 1412

第一章 EB安装

1.DemoWorkspace 是基于EB当前组件配置下的例程,包含了启动文件和中断服务函数以及组件demo。2.Mclsar 下存放的是EB的插件包和静态MCAL的驱动文件。

舊梦的博客 1954

宇树G1开发实践--PPT汇报(遥控版)

本文介绍了一种基于遥控器交互的机器人演示控制系统。系统通过DDS中间件接收遥控器信号,采用位掩码边沿检测技术实现按键精准响应,将不同按键映射为播放控制命令(暂停/重播、跳转、跳过等)。核心交互逻辑包含主播放循环、命令处理和暂停机制,支持播放过程中的实时控制。与自动顺序播放版相比,该系统显著提升了演示灵活性,适用于需要人机互动的演讲场景。使用前需确保网络连接和设备安全,并熟悉按键功能映射。该系统实现了专业级的人机协同演示体验。

m0_47999117的博客 680

Docker Networking Rules: EXPOSE, -p, -P, –link

http://www.centurylinklabs.com/docker-networking-rules/ If you've built any multi-container applications, chances are you've had to define some networking rules in order to allow traffic be

余功鹏的专栏 1648

【VTKExamples】PolyData-1:: CellEdgeNeighbors & CellPointNeighbors 检索Cell边相邻的Cells & 检索Cell点相邻的Cells

本文主要分享VTKExample中两个样例CellEdgeNeighbors.cxx & CellPointNeighbors.cxx,了解VTK中如何对Cell进行邻域检索!输入模型 基于Edge检索结果 基于Point检索结果目录前言1. 基于Edge检索核心代码2.基于Point检索核心代码3.基于Edge检索样例代码4. 基于Point检索样例代码1.

qq_40041064的博客 672

Walkthrough: Create and Run a Simple Windows Application In Native Code

  Walkthrough: Create and Run a Simple Windows Application In Native Code 8/28/2008 In this walkthrough you will create, build and run a simple Hello World

wyymaomi的专栏 739

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

(全英文)How to install and run a simple Asp.Net 5 Application in a Docker Container

Preface  This is my first time to write this technical document in English, maybe it has some grammar or explanation errors, pointed out and tell me, thank you from the bottom of my heart.  Let’s pr

mgsky1的博客 492

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

werkzeug serving.run_simple

参考: https://werkzeug.palletsprojects.com/en/1.0.x/serving/?highlight=run%20simple#werkzeug.serving.run_simple werkzeug.serving.run_simple(hostname, port, application, use_reloader=False, use_debugger=False, use_evalex=True, extra_files=None, reloader_inter

Claroja 847

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

simple-starter

simple-starter 是一个模块化 Rust 应用启动框架,基于宏与依赖注入,自动管理组件生命周期、配置、路由与安全。支持声明式组件注册、Trait 对象注入、分布式路由、定时任务、事件系统及插件化扩展,简化 Web 服务开发。核心模块 simple-starter-core 提供运行时引擎,各功能通过独立插件(如 Web、安全、调度)按需引入,零配置集成,专注业务逻辑。

qq_64000191的博客 877

如何安装并快速上手 WebUI X: Portable?5 步完成部署的快速教程(Root 与非 Root 模式全覆盖)

WebUI X: Portable(WXP)是 MMRL 出品的 Android WebUI 运行时与开发者工具,支持 KernelSU、Magisk、APatch 等 Root 环境,也提供非 Root(ADB)模式,让你直接在手机上运行、检查并调试模块的 WebUI 界面。本文用 5 个步骤带你完成 WebUI X 的安装与部署,Root 与非 Root 用户都能快速上手。 [![WebUI

gitblog_00244的博客 1018

Simple Form Bootstrap入门:从安装到部署的完整路线图

想要快速构建美观的Rails表单吗?😊 Simple Form Bootstrap是您的终极解决方案!这个强大的工具集成了Simple Form gem和Bootstrap框架,让创建专业级表单变得异常简单。无论您是Rails新手还是经验丰富的开发者,本文都将为您提供从零开始到完整部署的完整指南。 ## 🚀 什么是Simple Form Bootstrap? Simple Form Boo

gitblog_00790的博客 1000

如何在Rails项目中快速集成Simple Navigation导航库

Simple Navigation是一个功能强大的Ruby库,专为Rails、Sinatra和Padrino应用程序设计,能够轻松创建多级导航菜单。它支持多种渲染格式,包括HTML列表、链接列表和面包屑导航,是提升Rails应用用户体验的理想选择。 ## 📦 一键安装Simple Navigation 要在Rails项目中使用Simple Navigation,首先需要将gem添加到你的Ge

gitblog_00936的博客 1093

Simple TensorFlow Serving:5分钟快速部署机器学习模型的终极指南

你是否曾为机器学习模型的部署而烦恼?🤔 复杂的配置、繁琐的依赖、不同框架的兼容性问题... 这些问题让很多开发者在模型部署阶段望而却步。今天,我要向你介绍一个**简单易用**的解决方案——Simple TensorFlow Serving!🚀 这个开源项目能让你在**5分钟内**完成机器学习模型的快速部署,无论你是新手还是经验丰富的开发者,都能轻松上手。 Simple TensorFlow

gitblog_00308的博客 793

simple-starter-core

simple-starter-core 是 Rust 框架的运行时核心,基于编译期元数据注册与拓扑排序实现组件生命周期管理。支持依赖注入(类型、名称、trait 多模式)、插件系统(三阶段生命周期)、配置分层合并及条件注册。通过“记录+还原”机制解决 trait 对象注入难题,提供 Application 构建器与 AppContext 运行时工具,实现链式配置、启动/关闭钩子与自动资源释放,具备高可扩展性与安全性。

qq_64000191的博客 559

Simple TensorFlow Serving故障排除:常见问题与解决方案大全

Simple TensorFlow Serving作为通用且易用的机器学习模型服务框架,在实际部署和使用过程中可能会遇到各种问题。😊 本指南将为您提供完整的故障排除方案,帮助您快速解决常见问题,确保模型服务稳定运行。 ## 一、安装与启动问题排查 ### 1.1 安装失败:依赖包冲突 **问题现象**:使用`pip install simple_tensorflow_serving`时出现

gitblog_00707的博客 891

Simple Navigation与Padrino框架集成:构建现代Web应用导航系统

Simple Navigation是一款功能强大的Ruby库,专为Rails、Sinatra和Padrino应用程序创建多级导航系统。本文将详细介绍如何将Simple Navigation与Padrino框架无缝集成,帮助开发者快速构建专业、灵活的现代Web应用导航。 ## 🚀 为什么选择Simple Navigation? Simple Navigation为Padrino应用提供了完整的

gitblog_01076的博客 400

Simple TensorFlow Serving GPU加速配置:让你的模型推理速度提升10倍

Simple TensorFlow Serving是一款通用且易用的机器学习模型服务工具,通过GPU加速配置,能够显著提升模型推理性能。本文将详细介绍如何为Simple TensorFlow Serving配置GPU加速,让你的模型推理速度提升10倍,适用于各类深度学习应用场景。 ## 为什么选择GPU加速模型推理? 在深度学习模型推理过程中,GPU凭借其强大的并行计算能力,相比CPU能够提供

gitblog_00119的博客 698

sap netweaver application server java_SAP NetWeaver Application Server Java

Run Outside Discovery on the HostManual OperationsAs prerequisites, you shall install the SAP Host Agent and run Outside Discovery as described in page Preparing Outside Discovery.Install SAP NetWeave...

weixin_42138525的博客 599
上一篇: Hello world in a container
下一篇: Build Your Own Images
screaming
博客等级 码龄19年 60粉丝 6原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值