首页 > 其他 > 详细

centos 7 docker测试

时间:2018-05-19 21:19:50      阅读:225      评论:0      收藏:0      [点我收藏+]

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce
yum list docker-ce --showduplicates | sort -r
systemctl
systemctl start docker
docker version
systemctl enable docker

 

docker version
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:20:16 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm

 

docker run centos echo ‘hello world‘
Unable to find image ‘centos:latest‘ locally
latest: Pulling from library/centos
469cfcc7a4b3: Pull complete
Digest: sha256:989b936d56b1ace20ddf855a301741e52abca38286382cba7f44443210e96d16
Status: Downloaded newer image for centos:latest
hello world

 

docker run centos echo ‘hello world‘
hello world

 

docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest e934aafc2206 6 weeks ago 199MB

docker run -i -t --name=centos2 centos /bin/bash  #用镜像centos6创建容器,设置名称为centos2
[root@8be75c0a6f52 /]#

 

docker start centos2  以守护形式启动容器
centos2

docker ps 查看正在运行的容器
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6f115f1e1b40 centos "/bin/bash" 9 minutes ago Up 8 seconds centos3


[root@izwz98hlt9fisw6uu80b46z ~]# docker attach centos2  进入容器

 

docker ps -a  查看所有容器

docker inspect centos2 

 

docker run -i -t --name=centos3 centos /bin/bash

 

docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6f115f1e1b40 centos "/bin/bash" 50 seconds ago Exited (127) 10 seconds ago centos3
8be75c0a6f52 centos "/bin/bash" 14 minutes ago Exited (0) 9 minutes ago centos2
3099b0fdc926 centos "/bin/bash" 19 minutes ago Exited (0) 3 minutes ago angry_bassi
f9b3f780da23 centos "echo ‘hello world‘" 25 minutes ago Exited (0) 25 minutes ago pedantic_stonebraker
66d0e7b547b4 centos "echo ‘hello world‘" 25 minutes ago Exited (0) 25 minutes ago silly_brahma

centos 7 docker测试

原文:https://www.cnblogs.com/mattqiu/p/9061538.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!