docker 保持容器运行create的容器怎么运行

你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!
[root@cxp ~]# docker
centos:6.6
FATA[0000] Error response from daemon: No command specified
换个镜像试试看:
[root@cxp ~]# docker
docker: 'iamges' is not a docker command. See 'docker --help'.
[root@cxp ~]# docker
REPOSITORY
VIRTUAL SIZE
497e13ba472a
8 days ago
c967c4f0f4f7
8 days ago
285c3f7a44de
8 days ago
285c3f7a44de
8 days ago
4 weeks ago
4 weeks ago
[root@cxp ~]# docker
-it debian:7
FATA[0000] Error response from daemon: No command specified
[root@cxp ~]# docker
-it test:latest
0cdd7a94d9da204c1b6779faeedcbf413e2baaace5
[root@cxp ~]# docker
-it centos:6.6
FATA[0000] Error response from daemon: No command specified
[root@cxp ~]# docker
-it centos:centos6.6
FATA[0000] Error response from daemon: No command specified
[root@cxp ~]# docker create
ubuntu:14.10
FATA[0000] Error response from daemon: No command specified
看到没有只有个别的成功了!
简单来分析一下吧:
首先说明一下,黄色标记的两个镜像是我之前创建好的容器之后,commit生产新的镜像,其他没有生成容器的镜像是没有任何改动的原镜像。至于什么原因我也不太清楚??????
centos:6.6是不是重其他docker主机上迁移过来的?
错误很明显。FATA[0000] Error response from daemon: No command specified。就是说启动容器你没有指定cmd。
你可以试一下:docker create -it centos:centos6.6 /bin/bash。
至于成功的那两个,那是因为你commit之后的镜像继承了之前容器的cmd。所以不会有cmd缺失。你可以docker inspect看下image就知道了。
要回复问题请先或
要么牛逼,要么滚蛋
浏览: 10032
关注: 3 人Docker Remote API 如何使用? - 知乎60被浏览15406分享邀请回答31 条评论分享收藏感谢收起service docker stop
docker -d -H unix:///var/run/docker.sock -H 0.0.0.0:4243
之后就可以: curl http://127.0.0.1:4243/containers/json
109 条评论分享收藏感谢收起查看更多回答使用 Docker 容器应该避免的 10 个事情
我的图书馆
使用 Docker 容器应该避免的 10 个事情
So you finally surrendered to containers and discovered that it solves&a lot of problems and has&a lot of&advantages:First:&It’s immutable&– The, OS, Library versions, configurations, folders, application is there. You guarantee that the same image tested in QA will arrive land in the production with the same behaviour.Second: It’s lightweight&– The memory footprint of a container is too small. Instead of hundreds or thousands&of MBs, it will just allocate the memory for the main process plus some tens of MBs.Third:&It’s fast&– You can start a&container as fast as a single process takes to start. Instead of minutes, you can start a new container in at most some few seconds.
翻译于 1年前
1人 顶 此译文
当你最后投入容器的怀抱,发现它能解决很多问题,而且还具有众多的优点:第一:它是不可变的&– 操作系统,库版本,配置,文件夹和应用都是一样的。您可以使用通过相同QA测试的镜像,使产品具有相同的表现。第二:它是轻量级的&– 容器的内存占用非常小。不需要几百几千MB,它只要对主进程分配内存再加上几十MB。第三:它很快速&– 启动一个容器与启动一个单进程一样快。不需要几分钟,您可以在几秒钟内启动一个全新的容器。
But many users still treating containers just like typical virtual machines&and forget that they also have another great advantage besides many others:&It’s disposable.The&big&mantra&about containers:“Containers are&ephemeral”.This characteristic&“per se”&forces users to change their mindset on how they should handle a and I’ll explain what you should&NOT&do in containers to keep extracting the best benefits of it:
翻译于 1年前
2人 顶 此译文
但是,许多用户依然像对待典型的虚拟机那样对待容器。但是他们都忘记了除了与虚拟机相似的部分,容器还有一个很大的优点:它是一次性的。容器的&准则&:“容器是临时的”。这个特性“本身”促使用户改变他们关于使用和管理容器的习惯;我将会向您解释在容器中不应该做这些事,以确保最大地发挥容器的作用。
1) Don’t store data in containers&– A container can be stopped, destroyed, or replaced. An application version 1.0 running in container should be easily replaced by the version 1.1 without any impact or loss of data. For that reason, if you need to store data, store it in a volume, but take care if two containers write data on the same volume because it could cause corruption.& Make sure your applications are designed to write to shared data stores.2) Don’t ship your application in two pieces&– As some people see containers as a virtual machine. Most of them tend to think that they should deploy their application in existing running containers. That can be true during thedevelopment&phase&where you need to deploy an&but for a continuous deployment (cd) pipeline in&QA&and production, your application should be part of the image. Remember: Containers should beimmutable.
翻译于 1年前
3人 顶 此译文
其它翻译版本:1(点击译者名切换)
社会主义好
1) 不要在容器中存储数据&– &容器可能被停止,销毁,或替换。一个运行在容器中的程序版本1.0,应该很容易被1.1的版本替换且不影响或损失数据。有鉴于此,如果你需要存储数据,请存在卷中,并且注意如果两个容器在同一个卷上写数据会导致崩溃。确保你的应用被设计成在共享数据存储上写入。2) 不要将你的应用发布两份&– &一些人将容器视为虚拟机。他们中的大多数倾向于认为他们应该在现有的运行容器里发布自己的应用。在开发阶段这样是对的,此时你需要不断地部署与调试;但对于质量保证与生产中的一个连续部署的管道,你的应用本该成为镜像的一部分。记住:容器应该保持不变。
翻译于 1年前
0人 顶 此译文
其它翻译版本:1(点击译者名切换)
1) 不要在容器中存储数据。– 容器可能被停止,销毁或者替换。运行在容器中的应用,使用1.1版替换1.0版时应该不影响或丢失任何数据。鉴于此,如果您需要存储数据,请将数据存储在一个卷中,但是,请注意,如果两个容器对相同的卷写数据,应避免冲突。请确保您的应用可以共享数据存储。2) 不要将您的应用分成两部分– 由于一些人将容器当作虚拟机,他们中的大多数人倾向于认为应该将应用部署在正运行的容器中。这样做在开发状态等您需要连续部署和调试的情况下是可以的;但是,对于QA和产品部署中,您的应用应该是镜像的一部分。记住:容器应该是不可变的。
3) Don’t create large images&– A large image will only make it hard to distribute. Make sure that you have only the required&files and libraries to run your application/process. Don’t install unnecessary packages or run “updates”(yum update)&during builds.4) Don’t use a single layer&image&– To have a more rational use of the layered filesystem, always create your own base image layer for your OS, another layer for the security and user definition, another layer for the lib installation, another layer for the configuration, and finally another layer for the application. It will be easy to recreate &and manage an image, and easy to distribute.5) Don’t create images&from running containers&– In other terms, don’t use “docker commit” to create an image. This way to build an image is not reproducible and it’s not versionable,&and should be completely avoided. Always use a Dockerfile or any other S2I (source-to-image) approach that is totally reproducible.
翻译于 1年前
2人 顶 此译文
3) 不要创建超大镜像&– 一个超大镜像只会难以分发。确保你仅有运行你应用/进程的必需的文件和库。不要安装不必要的包或在创建中运行更新(yum更新)。4) 不要使用单层镜像&– 要对分层文件系统有更合理的使用,始终为你的操作系统创建你自己的基础镜像层,另外一层为安全和用户定义,一层为库的安装,一层为配置,最后一层为应用。这将易于重建和管理一个镜像,也易于分发。5) 不要为运行中的容器创建镜像&– 换言之,不要使用“docker commit”命令来创建镜像。这种创建镜像的方法是不可重现的也不能版本化,应该彻底避免。始终使用Dockerfile或任何其他的可完全重现的S2I(源至镜像)方法。
6) Don’t use only the “latest” tag&– The latest tag is just like the “SNAPSHOT” for Maven users. Tags are encouraged to be used specially when you have a layered filesytem. You don’t want to have surprises when you build your image 2 months later and figure out that your application can’t run&because a top layer was replaced by a new version that it’s not backward compatible or because a wrong “latest” version is in the build cache. The latest should also be avoided when deploying containers in production.7) Don’t run more than one process in a single container&– Containers are perfect to run a single process (http daemon, application server, database), but if you have more than a single process, you will have troubles to manage, get logs, and update them individually.
翻译于 1年前
3人 顶 此译文
6) 不要只使用“最新”标签&– 最新标签就像Maven用户的“快照”。标签是被鼓励使用的,尤其是当你有一个分层的文件系统。你总不希望当你2个月之后创建镜像时,惊讶地发现你的应用无法运行,因为最顶的分层被非向后兼容的新版本替换,或者创建缓存中有一个错误的“最新”版本。在生产中部署容器时应避免使用最新。7) 不要在单一容器中运行超过一个进程&– 容器能完美地运行单个进程(http守护进程,应用服务器,数据库),但是如果你不止有一个进程,管理、获取日志、独立更新都会遇到麻烦。
8) Don’t store credentials&in the image. Use environment variables&– You don’t want to hardcode any username/password in you image. Use the environment variables to get that information from outside the container. A great example for it is the&.9) Run processes with a non-root user&–&“By default docker containers run as root. (…) As docker matures, more secure default options may become available. For now, requiring root is dangerous for others and may not be available in all environments. Your image should use the USER instruction to specify a non-root user for containers to run as”. (From&)10) Don’t rely&on IP&addresses&– Each container have their own internal IP address and it could change if you start and stop it. If your application or microservices needs to communicate to another container, use any names and/or environment variables to pass the proper information from one container to another.
翻译于 1年前
2人 顶 此译文
8) 不要在镜像中存储凭据。使用环境变量&–不要将镜像中的任何用户名/密码写死。使用环境变量来从容器外部获取此信息。有一个不错的例子是。9) 使用非root用户运行进程&–&“docker容器默认以root运行。(…)随着docker的成熟,更多的安全默认选项变得可用。现如今,请求root对于其他人是危险的,可能无法在所有环境中可用。你的镜像应该使用USER指令来指令容器的一个非root用户来运行。”(来自 )10) 不要依赖IP地址&– 每个容器都有自己的内部IP地址,如果你启动并停止它地址可能会变化。如果你的应用或微服务需要与其他容器通讯,使用任何命名与(或者)环境变量来从一个容器传递合适信息到另一个。
TA的最新馆藏
喜欢该文的人也喜欢docker container create命令用于创建一个新的容器。
docker container create [OPTIONS] IMAGE [COMMAND] [ARG...]
名称,简写
--add-host
添加自定义的主机到IP映射(host:ip)
--attach, -a
附加到STDIN,STDOUT或STDERR
--blkio-weight
阻止IO(相对权重),介于10和1000之间,或0禁用(默认为0)
--blkio-weight-device
块IO的权重(相对设备权重)
添加Linux功能
--cap-drop
删除Linux功能
--cgroup-parent
容器的可选父cgroup
将容器ID写入文件
--cpu-count
CPU数量(仅限Windows)
--cpu-percent
CPU百分比(仅限Windows)
--cpu-period
限制CPU CFS(完全公平的调度程序)周期
--cpu-quota
限制CPU CFS(完全公平的调度程序)配额
--cpu-rt-period
限制CPU实时周期(以微秒为单位)
--cpu-rt-runtime
以微秒限制CPU实时运行时间
--cpu-shares, -c
CPU份额(相对重量)
--cpuset-cpus
允许执行的CPU(0-3,0)
--cpuset-mems
允许执行的内存(0-3,0.1)
--credentialspec
托管服务帐户的凭证规格(仅适用于Windows)
将主机设备添加到容器
--device-read-bps
从设备限制读取速率(每秒字节数)
--device-read-iops
从设备限制读取速率(每秒IO)
--device-write-bps
限制设备的写入速率(每秒字节数)
--device-write-iops
限制写入到设备的速率(IO每秒)
--disable-content-trust
跳过映像验证
设置自定义DNS服务器
设置DNS选项
--dns-option
设置DNS选项
--dns-search
设置自定义DNS搜索域
--entrypoint
覆盖映像的默认ENTRYPOINT
设置环境变量
--env-file
读入环境变量文件
暴露端口或端口范围
--group-add
添加其他组加入
--health-cmd
运行命令检查健康状况
--health-interval
运行检查之间的时间(*ns
h*)(默认值0s)
--health-retries
连续失败需要报告不健康
--health-timeout
允许一次检查运行的最长时间(*ns
h*)(默认值0s)
打印使用情况
--hostname, -h
容器主机名
在容器内初始化运行一个转发信号并收集进程
--init-path
docker-init二进制文件的路径
--interactive, -i
保持STDIN打开即使不附加
--io-maxbandwidth
系统驱动器的最大IO带宽限制(仅限Windows)
--io-maxiops
系统驱动器的最大IOPS限制(仅限Windows)
容器IPv4地址(例如:172.30.100.104)
容器IPv6地址(例如:2001:db8::33)
IPC命名空间使用
--isolation
容器隔离技术
--kernel-memory
内核内存限制
--label, -l
在容器上设置元数据
--label-file
读取标签的行分隔文件
添加链接到另一个容器
--link-local-ip
添加链接到另一个容器
--log-driver
记录容器的驱动程序
日志驱动程序选项
--mac-address
容器MAC地址(例如:92:d0:c6:0a:29:33)
--memory, -m
--memory-reservation
内存软限制
--memory-swap
交换限制等于内存加交换:’-1‘以启用无限制的交换
--memory-swappiness
调整容器内存swappiness(0到100)
为容器指定名称
将容器连接到网络
--net-alias
为容器添加网络范围的别名
将容器连接到网络
--network-alias
为容器添加网络范围的别名
--no-healthcheck
禁用任何容器指定的HEALTHCHECK
--oom-kill-disable
--oom-score-adj
调整主机的OOM偏好设置(-1000至1000)
要使用的PID命名空间
--pids-limit
调整容器pids限制(设置为-1为无限制)
--privileged
为此容器提供扩展权限
--publish, -p
将容器的端口发布到主机
--publish-all, -P
将所有暴露的端口发布到随机端口
--read-only
将容器的根文件系统挂载为只读
重新启动在容器退出时应用的策略
退出时自动取出容器
运行时用于此容器
--security-opt
--shm-size
/dev/shm的大小,默认值为64MB
--stop-signal
信号停止容器,默认情况下为SIGTERM
--stop-timeout
超时(秒)停止容器
--storage-opt
容器的存储驱动程序选项
Sysctl 选项
装载一个 tmpfs 目录
分配一个 pseudo-TTY
Ulimit选项
--user, -u
Username 或 UID (格式: &name
uid&[:&group
要使用的用户名空间
使用UTS命名空间
--volume, -v
--volume-driver
容器的可选卷驱动程序
--volumes-from
指定容器以装载卷
--workdir, -w
容器内的工作目录
附加到正在运行的容器
从容器的更改创建一个新的映像
在容器和本地文件系统之间复制文件/文件夹
创建一个新的容器
检查容器文件系统上文件或目录的更改
在运行容器中运行命令
将容器的文件系统导出为tar存档
显示一个或多个容器的详细信息
杀死一个或多个运行容器
获取容器的日志
暂停一个或多个容器内的所有进程
列出端口映射或容器的特定映射
取出所有停止的容器
重命名容器
重新启动一个或多个容器
删除(移除)一个或多个容器
在新容器中运行命令
启动一个或多个停止的容器
显示容器的实时流资源使用统计信息
停止一个或多个运行容器
显示容器的正在运行的进程
取消暂停一个或多个容器内的所有流程
更新一个或多个容器的配置
阻止一个或多个容器停止,然后打印退出代码
加QQ群啦!
JAVA技术群:
MySQL/SQL群:
Python技术群:
大数据开发群: (Java,Python,R,Scala,Hadoop,Spark,zookeeper,kafka等技术)
Web开发群(新群):
(PHP,HTML/HTML5,JS/JQuery,CSS等技术)
Linux技术群(新群): (Redhat/Centos,Ubuntu,Shell,运维,监控等技术)
易百教程移动端:请扫描本页面底部(右侧)二维码关注微信公众号,或直接手机访问:
上一篇:下一篇:哥,这回真没有了}

我要回帖

更多关于 docker 运行的容器 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信