docker 命令及问题

 

一些常用Docker命令,更多命令详解,请访问:http://www.docker.org.cn/dockerppt/106.html

 -----------------     docker ps 查看当前正在运行的容器

 -----------------    docker ps -a 查看所有容器的状态

 -----------------    docker start/stop id/name 启动/停止某个容器

 -----------------    docker attach id 进入某个容器(使用exit退出后容器也跟着停止运行)

 -----------------    docker exec -ti id 启动一个伪终端以交互式的方式进入某个容器(使用exit退出后容器不停止运行)

 -----------------    docker images 查看本地镜像
 -----------------    docker rm id/name 删除某个容器
-----------------     docker rmi id/name 删除某个镜像

 -----------------    docker run --name test -ti ubuntu /bin/bash  复制ubuntu容器并且重命名为test且运行,然后以伪终端交互式方式进入容器,运行bash

-----------------     docker build -t soar/centos:7.1 .  通过当前目录下的Dockerfile创建一个名为soar/centos:7.1的镜像

 -----------------    docker run -d -p 2222:22 --name test soar/centos:7.1  以镜像soar/centos:7.1创建名为test的容器,并以后台模式运行,并做端口映射到宿主机2222端口,P参数重启容器宿主机端口会发生改变

 

docker 拉取镜像操作

查看镜像

[root@izuf6400c3ysl2hbzveiciz ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tomcat              latest              a7fa4ac97be4        8 days ago          528MB

搜索镜像

docker search  xxx    (xxx是你搜索的镜像名)

[root@izuf6400c3ysl2hbzveiciz ~]# docker search tomcat
NAME                          DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
tomcat                        Apache Tomcat is an open source implementati…   2676                [OK]                
tomee                         Apache TomEE is an all-Apache Java EE certif…   76                  [OK]                
dordoka/tomcat                Ubuntu 14.04, Oracle JDK 8 and Tomcat 8 base…   53          

拉取镜像

docker pull [options]Name[:TAG|@DIGEST]

[options]:是否开启镜像校验等参数,可选
[:TAG|@DIGEST]:镜像指定的TAG版本,可选

[root@izuf6400c3ysl2hbzveiciz ~]# docker pull tomcat
Using default tag: latest
latest: Pulling from library/tomcat
50e431f79093: Pull complete 
dd8c6d374ea5: Pull complete 
c85513200d84: Pull complete 
55769680e827: Pull complete 
e27ce2095ec2: Pull complete 
5943eea6cb7c: Pull complete 
3ed8ceae72a6: Pull complete 
91d1e510d72b: Pull complete 
415cc4506e71: Pull complete 
a79d88064227: Pull complete 
Digest: sha256:b707d3b8b4f40951ca2f387c24ab9f78800c69c90740f0cca937a1b95204b3a4
Status: Downloaded newer image for tomcat:latest
[root@izuf6400c3ysl2hbzveiciz ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tomcat              latest              a7fa4ac97be4        8 days ago          528MB

第一次在拉取的时候发现很慢,我们采用的阿里云仓库,于是可以使用阿里云的镜像加速
操作参考https://www.cnblogs.com/BillyYoung/p/11113914.html

通过创建dackerfile镜像

先在home/px2/tmp文件中上传DockerFile,和index.html
进入文件目录执行 

[root@izuf6400c3ysl2hbzveiciz ~]# docker build -t mytomcat .

docker  镜像容器化操作

-d:容器后台运行

-p 8080:10000 容器1000端口映射到服务器的8080端口

-name tomcat_test: 指定容器名字为tomcat_test


tomcat:镜像名称

[root@izuf6400c3ysl2hbzveiciz ~]# docker run -d -p 8080:10000 --name tomcat_test tomcat
8e5eab247fb07fa9fdb1183a036a9eb66c222270c71f3a158e7855c757022a76

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值