阿里云部署Docker(4)----容器的使用
通过上一节的学习,我们知道怎样执行docker容器,我们执行了一个普通的,一个后台的,我们还学习了几个指令:
docker ps - Lists containers.
docker logs - Shows us the standard output of a container.
docker stop - Stops running containers.
我们还能够查看下docker的版本号:
root@iZ28ikebrg6Z:~# docker version
Client version: 1.2.0
Client API version: 1.14
Go version (client): go1.3.1
Git commit (client): fa7b24f
OS/Arch (client): linux/amd64
Server version: 1.2.0
Server API version: 1.14
Go version (server): go1.3.1
Git commit (server): fa7b24f
root@iZ28ikebrg6Z:~#
docker是基于google公司的Go语言的。
假设不知道docker怎么用,或者忘记了的时候,直接输入docker。会给出使用方法提示
root@iZ28ikebrg6Z:~# docker
Usage: docker [OPTIONS] COMMAND [arg...]
-H=[unix:///var/run/docker.sock]: tcp://host:port to bind/connect to or unix://path/to/socket to use A self-sufficient runtime for linux containers. Commands:
attach Attach to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders from a container's filesystem to the host path
diff Inspect changes on a container's filesystem
events Get real time events from the server
export Stream the contents of a container as a tar archive
history Show the history of an image
images List images
import Create a new filesystem image from the contents of a tarball
info Display system-wide information
inspect Return low-level information on a container
kill Kill a running container
load Load an image from a tar archive
login Register or log in to a Docker registry server
logout Log out from a Docker registry server
logs Fetch the logs of a container
port Lookup the public-facing port that is NAT-ed to PRIVATE_PORT
pause Pause all processes within a container
ps List containers
pull Pull an image or a repository from a Docker registry server
push Push an image or a repository to a Docker registry server
restart Restart a running container
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save an image to a tar archive
search Search for an image on the Docker Hub
start Start a stopped container
stop Stop a running container
tag Tag an image into a repository
top Lookup the running processes of a container
unpause Unpause a paused container
version Show the Docker version information
wait Block until a container stops, then print its exit code root@iZ28ikebrg6Z:~#
docker后面跟指令,
root@iZ28ikebrg6Z:~# docker attach Usage: docker attach [OPTIONS] CONTAINER Attach to a running container --no-stdin=false Do not attach STDIN
--sig-proxy=true Proxy all received signals to the process (even in non-TTY mode). SIGCHLD, SIGKILL, and SIGSTOP are not proxied.
root@iZ28ikebrg6Z:~#
假设输入非法,总是会给出提示,告诉你怎么用。
Running a Web Application in Docker
利用Docker构建一个web程序
我们运行一个web应用。
root@iZ28ikebrg6Z:~# docker run -d -P training/weapp python app.py
Unable to find image 'training/weapp' locally
Pulling repository training/weapp
2014/10/16 11:01:56 Error: image training/weapp not found
root@iZ28ikebrg6Z:~# docker run -d -P training/webapp python app.py
Unable to find image 'training/webapp' locally
Pulling repository training/webapp
31fa814ba25a: Pulling dependent layers
511136ea3c5a: Download complete
f10ebce2c0e1: Download complete
82cdea7ab5b5: Download complete
5dbd9cb5a02f: Download complete
31fa814ba25a: Download complete
64523f641a05: Download complete
0e2afc9aad6e: Download complete
e8fc7643ceb1: Download complete
733b0e3dbcee: Download complete
a1feb043c441: Download complete
e12923494f6a: Download complete
a15f98c46748: Download complete
09792841c0b448a330a89ee656b4a16605d835f9d43bb7d6f80f204b6e8ed5b2
root@iZ28ikebrg6Z:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
09792841c0b4 training/webapp:latest "python app.py" 54 minutes ago Up 54 minutes 0.0.0.0:49153->5000/tcp compassionate_torvalds
root@iZ28ikebrg6Z:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
09792841c0b4 training/webapp:latest "python app.py" 56 minutes ago Up 56 minutes 0.0.0.0:49153->5000/tcp compassionate_torvalds
root@iZ28ikebrg6Z:~#
第一次敲错了。第二次它会去docker库下载,下载完了,ps查看一下。多了一行Ports。
表示将本机的49153port映射到compassionate_toralds容器的5000port。
我用浏览器试一下。-d选项。我们已经讲过,是将程序后台化。-P,大写的P,是让docker来指定一个port映射。
这里是49153,你能够通过-p小写的来指定这样的映射关系。
例如以下效果:
好,能够訪问。
哈哈。
root@iZ28ikebrg6Z:~# docker run -d -p 5000:5000 training/webapp python app.py
aa47ba8e71c8512f228a96bf80da117b6c86fc03bdb17eef1c2db353a3e18493
好。再訪问一下。
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTWluaU1pY2FsbA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">
阿里云部署Docker(4)----容器的使用的更多相关文章
- 阿里云部署Docker(5)----管理和公布您的镜像
出到这节,我在百度搜索了一下"阿里云部署Docker",突然发现怎么会有人跟我写的一样呢?哦,原来是其它博客系统的爬虫来抓取,然后也不会写转载自什么什么的.所以,我最终明确为什么那 ...
- 阿里云部署Docker(7)----将容器连接起来
路遥知马力.日久见人心.恩. 该坚持的还是要坚持. 今天看到一个迅雷的师弟去了阿里,祝福他,哎,尽管老是被人家捧着叫大牛.我说不定通过不了人家的面试呢.哎,心有惭愧. 本文为本人原创,转载请表明来源: ...
- 阿里云部署Docker(2)
之前有一篇文章讲过在阿里云中安装Docker,相对来说那个是安装.可是安装完之后我们通常会碰到问题. 今天我给大家记录一下我的新的解决过程. 环境还是ubuntu12.04.如果我们已经把内核升级到了 ...
- 阿里云部署Docker(3)----指令学习
通过上两节的学习http://blog.csdn.net/minimicall/article/details/40119177 和http://blog.csdn.net/minimicall/ar ...
- 阿里云部署Docker(8)----安装和使用redmine
安装redmine对过程进行管理. 须要说明的是:当你在docker images的时候,会说没连接到xxxx的时候,并且会提示用"docker -d".事实上这仅仅是把docke ...
- 阿里云部署Docker(6)----解决删除<none>镜像问题
转载请注明来源,本博客原创作者为:http://blog.csdn.net/minimicall?viewmode=contents 在Docker使用中,常常会碰到删除镜像不成功.反而让镜像变成了& ...
- 阿里云部署Docker(9)----Dockerfile脚本定制镜像
本文为原创文章.转载需注明转自:http://blog.csdn.net/minimicall? viewmode=contents 技术爱好者都是比較懒的.而docker又是开发人员支持起来的.所以 ...
- 阿里云服务器安装Docker并部署nginx、jdk、redis、mysql
阿里云服务器安装Docker并部署nginx.jdk.redis.mysql 一.安装Docker 1.安装Docker的依赖库 yum install -y yum-utils device-map ...
- 阿里云-部署-服务-Docker
目录 ♫ MusicPlayer Naiveboom - 比较安全 个人阿里云部署的小服务,欢迎使用,服务器资源有限,如果遇到卡顿还请谅解~ 索引: 在线音乐播放器 阅后即焚 ♫ MusicPlaye ...
随机推荐
- 新增加的HTTP状态码 -- 103
IETF公布了新的HTTP状态码-103, 总结一下就是提前预加载(css.js)文档,提升用户的访问速度. Summary: a new status code that lets the serv ...
- C#设计模式之十三代理模式(Proxy)【结构型】
一.引言 今天我们要讲[结构型]设计模式的第七个模式,也是"结构型"设计模式中的最后一个模式,该模式是[代理模式],英文名称是:Proxy Pattern.还是老套路,先从名字 ...
- 从零开始搭建Vue组件库 VV-UI
前言: 前端组件化是当今热议的话题之一,也是我们在开发单页应用经常会碰到的一个问题,现在我们有了功能非常完善的Element-UI.各个大厂也相继宣布开源XXX-UI.但是也会存在一些问题,比如每个公 ...
- sql 1.1 1.1.1 1.10.1 排序
解决思路:计算每位的权重,得到序号完整的权重值,使用权重值进行排序! 创建sql 函数如下: ALTER FUNCTION [dbo].[SequenceToOrderNum] ( @Sequence ...
- 微软Connect(); 2017大会梳理:Azure、数据、AI开发工具
在今天召开的 Connect(); 2017 开发者大会上,微软宣布了 Azure.数据.AI 开发工具的内容.这是第一天的 Connect(); 2017 的主题演讲. 在开场视频中霍金又来了.你记 ...
- C#中的DBNull、Null、""和String.Empty
1.对DBNull的解释: 该类用于指示不存在某个已知值(通常在数据库应用程序中). 在数据库应用程序中,空对象是字段的有效值.该类区分空值(空对象)和未初始化值(DBNull.Va ...
- 社群公会GangSDK:程序员入行AI领域需要哪些技能?
作为一名Android开发工程师,身边总有些同行很焦虑,看着人工智能越来越火,总是担心Android要不行了,所以,我们需要转行么?Android还能走多久?其实,无论是对于Android还是iOS开 ...
- 使用canvas绘制时钟 (http://heeroluo.net/Article/Detail/95)
准备工作 在HTML中指定一个区域放置时钟: <div id="clock" style="position: relative;"></di ...
- [C#]使用TcpListener及TcpClient开发一个简单的Chat工具
本文为原创文章.源代码为原创代码,如转载/复制,请在网页/代码处明显位置标明原文名称.作者及网址,谢谢! 本文使用的开发环境是VS2017及dotNet4.0,写此随笔的目的是给自己及新开发人员作为参 ...
- Vue-cli创建项目从单页面到多页面2-history模式
之前讲过怎样将vue-cli创建的项目改造成多页面(vue-cli创建项目从单页面到多页面),今天说一下怎样在多页面的前提下使用history模式. 如何使用history模式 因为vue默认的has ...