如何让docker daemon以daemon方式运行/bin/bash

Docker 使用方法小结之:镜像 - 云计算当前位置:& &&&Docker 使用方法小结之:镜像Docker 使用方法小结之:镜像&&网友分享于:&&浏览:0次Docker 使用方法总结之:镜像
命令:docker search [OPTIONS] TERM
相关参数:
Search the Docker Hub for images
& --automated=false&&& Only show automated builds
& --no-trunc=false&&&& Don't truncate output
& -s, --stars=0&&&&&&& Only displays with at least x stars
[ ~]# docker search mysql
NAME&&&&&&&&&&&&&&&&&&&&&&&& DESCRIPTION&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& STARS&&&& OFFICIAL&& AUTOMATED
mysql&&&&&&&&&&&&&&&&&&&&&&& MySQL is a widely used, open-source relati...&& 655&&&&&& [OK]&&&&& &
tutum/mysql&&&&&&&&&&&&&&&&& MySQL Server image - listens in port 3306....&& 115&&&&&&&&&&&&&&&&& [OK]
orchardup/mysql&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 37&&&&&&&&&&&&&&&&&& [OK]
centurylink/mysql&&&&&&&&&&& Image containing mysql. Optimized to be li...&& 21&&&&&&&&&&&&&&&&&& [OK]
...................
命令:docker pull [OPTIONS] NAME[:TAG]
参数:& -a, --all-tags=false&&& Download all tagged images in the repository
[ ~]# docker pull tutum/mysql
Pulling repository tutum/mysql
26c0c52dc79a: Pulling dependent layers
c5a: Download complete
27d47432a69b: Download complete
5f92234dcf1e: Download complete
51a9c7c1f8bb: Download complete
5ba9dab47459: Download complete
d26d9affc74e: Download complete
c8420faa4614: Download complete
命令:docker run -t -i tutum/mysql /bin/bash
命令:docker images [OPTIONS] [NAME]
& -a, --all=false&&&&& Show all images (by default filter out the intermediate image layers)
& -f, --filter=[]&&&&& Provide filter values (i.e. 'dangling=true')
& --no-trunc=false&&&& Don't truncate output
& -q, --quiet=false&&& Only show numeric IDs
[ ~]# docker images -a
REPOSITORY&&&&&&&&&&& TAG&&&&&&&&&&&&&&&& IMAGE ID&&&&&&&&&&& CREATED&&&&&&&&&&&& VIRTUAL SIZE
&none&&&&&&&&&&&&&&&& &none&&&&&&&&&&&&&& 6941bfcbbfca&&&&&&& 10 days ago&&&&&&&& 0 B
eric/ubuntu&&&&&&&&&& latest&&&&&&&&&&&&& &&&&&&& 6 weeks ago&&&&&&&& 270.3 MB
&none&&&&&&&&&&&&&&&& &none&&&&&&&&&&&&&& c8420faa4614&&&&&&& 3 months ago&&&&&&& 192.7 MB
&none&&&&&&&&&&&&&&&& &none&&&&&&&&&&&&&& d26d9affc74e&&&&&&& 3 months ago&&&&&&& 192.7 MB
&none&&&&&&&&&&&&&&&& &none&&&&&&&&&&&&&& 5ba9dab47459&&&&&&& 3 months ago&&&&&&& 192.7 MB更改TAG
更改之前:
[ ~]# docker images
REPOSITORY&&&&&&&&&&& TAG&&&&&&&&&&&&&&&& IMAGE ID&&&&&&&&&&& CREATED&&&&&&&&&&&& VIRTUAL SIZE
centos&&&&&&&&&&&&&&& 7&&&&&&&&&&&&&&&&&& fd44297e2ddb&&&&&&& 10 days ago&&&&&&&& 229.6 MB
centos&&&&&&&&&&&&&&& centos7&&&&&&&&&&&& fd44297e2ddb&&&&&&& 10 days ago&&&&&&&& 229.6 MB
centos&&&&&&&&&&&&&&& latest&&&&&&&&&&&&& fd44297e2ddb&&&&&&& 10 days ago&&&&&&&& 229.6 MB
eric/ubuntu&&&&&&&&&& latest&&&&&&&&&&&&& &&&&&&& 6 weeks ago&&&&&&&& 270.3 MB
tutum/mysql&&&&&&&&&& latest&&&&&&&&&&&&& 26c0c52dc79a&&&&&&& 3 months ago&&&&&&& 322.5 MB
centos_6_5&&&&&&&&&&& ansible&&&&&&&&&&&& f01c1b138488&&&&&&& 10 months ago&&&&&& 322.4 MB
chug/ubuntu12.10x64&& latest&&&&&&&&&&&&& 0b96c14dafcd&&&&&&& 13 months ago&&&&&& 270.3 MB
docker tag tutum/mysql:latest localrepo:newtag
[ ~]# docker images
REPOSITORY&&&&&&&&&&& TAG&&&&&&&&&&&&&&&& IMAGE ID&&&&&&&&&&& CREATED&&&&&&&&&&&& VIRTUAL SIZE
centos&&&&&&&&&&&&&&& 7&&&&&&&&&&&&&&&&&& fd44297e2ddb&&&&&&& 10 days ago&&&&&&&& 229.6 MB
centos&&&&&&&&&&&&&&& centos7&&&&&&&&&&&& fd44297e2ddb&&&&&&& 10 days ago&&&&&&&& 229.6 MB
centos&&&&&&&&&&&&&&& latest&&&&&&&&&&&&& fd44297e2ddb&&&&&&& 10 days ago&&&&&&&& 229.6 MB
eric/ubuntu&&&&&&&&&& latest&&&&&&&&&&&&& &&&&&&& 6 weeks ago&&&&&&&& 270.3 MB
tutum/mysql&&&&&&&&&& latest&&&&&&&&&&&&& 26c0c52dc79a&&&&&&& 3 months ago&&&&&&& 322.5 MB
localrepo&&&&&&&&&&&& newtag&&&&&&&&&&&&& 26c0c52dc79a&&&&&&& 3 months ago&&&&&&& 322.5 MB
centos_6_5&&&&&&&&&&& ansible&&&&&&&&&&&& f01c1b138488&&&&&&& 10 months ago&&&&&& 322.4 MB
chug/ubuntu12.10x64&& latest&&&&&&&&&&&&& 0b96c14dafcd&&&&&&& 13 months ago&&&&&& 270.3 MB
命令:docker inspect [OPTIONS] CONTAINER|IMAGE [CONTAINER|IMAGE...]
参数:-f, --format=&&&&& Format the output using the given go template.
[ ~]# docker inspect f01c1b138488
命令:docker rmi [OPTIONS] IMAGE [IMAGE...]
-f, --force=false&&& Force removal of the image
--no-prune=false&&&& Do not delete untagged parents
[ ~]# docker rmi 26c
Error response from daemon: Conflict, cannot delete 26c0c52dc79a because the container 002ca178e599 is using it, use -f to force
上面出错的原因是因为该镜像正在被002ca178e599的容器使用,所以不能删除,所以首先需要使用docker rm删除容器,然后再删除,相关的AUFS文件也会被删除
[ ~]# docker rm 002
[ ~]# docker rmi 26c
Untagged: localrepo:newtag
Deleted: 26c0c52dc79af8acf07a18cd1693bfaeee4d1c1dbe29ac0
Deleted: baa82675eeee78a2e18cca3cf33f372be4b
Deleted: 6d79ac2cce944a7f485fc31acf7e44fb210
Deleted: cb6a06a808d4329b1bba405b9e3e733b1c379fbe918f6c14c6023a
Deleted: 8d466d27bccade0e6fc28fa8a46e32b5b453e7387a61eef7c1be8a
基于Container创建
启动一个容器
[ ~]# docker run -ti f01 /bin/bash在启动的容器中安装ansible,git等工具
查询Container ID
[ ~]# docker ps
CONTAINER ID&&&&&&& IMAGE&&&&&&&&&&&&&&& COMMAND&&&&&&&&&&&& CREATED&&&&&&&&&&&& STATUS&&&&&&&&&&&&& PORTS&&&&&&&&&&&&&& NAMES
52ec&&&&&&& centos_6_5:ansible&& &/bin/bash&&&&&&&&& 31 seconds ago&&&&& Up 30 seconds&&&&&&&&&&&&&&&&&&&&&&&&&& high_mcclintock
执行创建命令,返回值就是生成的Image ID
[ ~]# docker commit -m 'Ansible Image,and git, sample yml files' -a 'Eric.sunah' 52ec eric/ansible
6ee1aba47aefedbf9ad293eaf查看新的列表
[ ~]# docker images
REPOSITORY&&&&&&&&&&& TAG&&&&&&&&&&&&&&&& IMAGE ID&&&&&&&&&&& CREATED&&&&&&&&&&&& VIRTUAL SIZE
eric/ansible&&&&&&&&& latest&&&&&&&&&&&&& 6ee1&&&&&&& 2 minutes ago&&&&&& 629.7 MB
eric/ubuntu&&&&&&&&&& latest&&&&&&&&&&&&& &&&&&&& 6 weeks ago&&&&&&&& 270.3 MB
centos_6_5&&&&&&&&&&& ansible&&&&&&&&&&&& f01c1b138488&&&&&&& 10 months ago&&&&&& 322.4 MB
chug/ubuntu12.10x64&& latest&&&&&&&&&&&&& 0b96c14dafcd&&&&&&& 13 months ago&&&&&& 270.3 MB
命令:docker save [OPTIONS] IMAGE [IMAGE...]
参数:& -o, --output=&&&&& Write to a file, instead of STDOUT
docker save -o centos6_ansible.tar eric/ansible
&命令:docker load [OPTIONS]
参数:& &-i, --input=&&&&&& Read from a tar archive file, instead of STDIN
docker load --input centos6_ansible.tar
首先取个便于识别的TAG
[ ~]# docker tag 6e38 sun7545526/template:ansible
[ ~]# docker images
REPOSITORY&&&&&&&&&&& TAG&&&&&&&&&&&&&&&& IMAGE ID&&&&&&&&&&& CREATED&&&&&&&&&&&& VIRTUAL SIZE
sun7545526/template&& ansible&&&&&&&&&&&& 6ee1&&&&&&& 17 minutes ago&&&&& 629.7 MB
eric/ansible&&&&&&&&& latest&&&&&&&&&&&&& 6ee1&&&&&&& 17 minutes ago&&&&& 629.7 MB
执行上传命令,第一次上传的时候会要求输入用户名,密码,邮箱信息:
[ ~]# docker push sun7545526/template:ansible
The push refers to a repository [sun7545526/template] (len: 1)
Sending image list
Pushing repository sun7545526/template (1 tags)
c5a: Image already pushed, skipping
1d6ebc5c68b1: Image already pushed, skipping
f01c1b138488: Image already pushed, skipping
6ee1: Image successfully pushed
Pushing tag for rev [6ee1] on {https://cdn-registry-1.docker.io/v1/repositories/sun7545526/template/tags/ansible}
12345678910
12345678910
12345678910 上一篇:没有了下一篇:文章评论相关解决方案 1234567891011 Copyright & &&版权所有如何让docker以daemon方式运行/bin/bash_百度知道
如何让docker以daemon方式运行/bin/bash
提问者采纳
便可以ssh登陆容器了;init.,so。注意您好ssh远程登陆一个容器----内容开始-----启动了一个容器之后;VERSION &#47,需要安装一个apt-get install openssh-server# 设置一个初始密码passwd 123;etc&#47,并让生成的容器一直在后台运行:docker commit CONTAINER_ID NAME&#47..d/VERSION最后。# 查询容器IPdocker inspect CONTAINER_ID | grep IP# 登入ssh root@IP# 输入密码 123完成登陆# 为保证安全,运行镜像,我们可能需要用ssh登陆进去进行一些操作.然后。openssh-server处于启动状态:以下示例是在ubuntu&#47,不然容器启动后立刻就变为停止状态了docker run -d NAME/ssh start -D现在;13,有2点需要保证,提交镜像:# 第一个-d表示让容器在后台运行# 末尾的-D表示启动ssh的daemon模式:容器必须处于运行状态.10中完成的首先确保镜像安装有openssh-server服务# 官方镜像一般没有安装ssh服务端。为达到此目的
网络营销专家
相关专业回答
docker run指定的命令如果不是那些一直挂起的命令(比如运行top,不断echo),就是会自动退出的。-d命令是设置detach为true,根据官方的文档,意思是让这个命令在后台运行,但并不是一直运行(我们在一个正常的Linux Terminal中运行/bin/bash,运行完了也就完了,不会一直挂着等待响应的,所以确实没办法用daemon方式来跑/bin/bash)。
这个地方官方早期...
其他类似问题
为您推荐:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁如何让docker以daemon方式运行/bin/bash_百度知道
如何让docker以daemon方式运行/bin/bash
我有更好的答案
8;bash -c & do ping 8docker 加 -d 就可以了,比如;bin/ done&quot.8.8。 # docker run --name centos-linux -d centos &#47
其他类似问题
为您推荐:
daemon的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁

我要回帖

更多关于 docker bin bash 的文章

 

随机推荐