CentOS7.2下安装Docker并运行第一个容器
来源:互联网 发布:三国乱世盘古辅助淘宝 编辑:程序博客网 时间:2024/06/08 00:49
要求内核版本高于3.10的64位系统支持Docker
[root@localhost imagedb]# uname -a
Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost imagedb]# more /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
使用yum安装Docker(保证主机能上网)
[root@localhost imagedb]#yum install docker
查看Docker已经安装
[root@localhost imagedb]#rpm -qa | grep docker
docker-client-1.12.6-55.gitc4618fb.el7.centos.x86_64
docker-1.12.6-55.gitc4618fb.el7.centos.x86_64
docker-common-1.12.6-55.gitc4618fb.el7.centos.x86_64
启动docker
[root@localhost imagedb]# systemctl start docker.service
查看docker版本
[root@localhost ~]# docker version
Client:
Version: 1.12.6
API version: 1.24
Package version: docker-1.12.6-55.gitc4618fb.el7.centos.x86_64
Go version: go1.8.3
Git commit: c4618fb/1.12.6
Built: Thu Sep 21 22:33:52 2017
OS/Arch: linux/amd64
Server:
Version: 1.12.6
API version: 1.24
Package version: docker-1.12.6-55.gitc4618fb.el7.centos.x86_64
Go version: go1.8.3
Git commit: c4618fb/1.12.6
Built: Thu Sep 21 22:33:52 2017
OS/Arch: linux/amd64
测试运行hello word
[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ...
latest: Pulling from docker.io/library/hello-world
5b0f327be733: Pull complete
Digest: sha256:1f19634d26995c320618d94e6f29c09c6589d5df3c063287a00e6de8458f8242
下载并加载我们的第一个centos容器(下载时间很长)
[root@localhost ~]# docker run -i -t centos
Unable to find image 'centos:latest' locally
Trying to pull repository docker.io/library/centos ...
latest: Pulling from docker.io/library/centos
d9aaf4d82f24: Pull complete
Digest: sha256:eba772bac22c86d7d6e72421b4700c3f894ab6e35475a34014ff8de74c10872e
[root@3af0e01415a4 /]#
查看使用第一个容器
[root@3af0e01415a4 /]# more /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@3af0e01415a4 /]# hostname
3af0e01415a4
[root@3af0e01415a4 /]# more /etc/host
host.conf hostname hosts hosts.allow hosts.deny
[root@3af0e01415a4 /]# more /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2 3af0e01415a4
[root@3af0e01415a4 /]# ping www.hao123.com
PING hao123.n.shifen.com (115.239.217.167) 56(84) bytes of data.
64 bytes from 115.239.217.167 (115.239.217.167): icmp_seq=1 ttl=127 time=76.3 ms
64 bytes from 115.239.217.167 (115.239.217.167): icmp_seq=2 ttl=127 time=47.2 ms
64 bytes from 115.239.217.167 (115.239.217.167): icmp_seq=3 ttl=127 time=47.9 ms
64 bytes from 115.239.217.167 (115.239.217.167): icmp_seq=4 ttl=127 time=47.2 ms
64 bytes from 115.239.217.167 (115.239.217.167): icmp_seq=5 ttl=127 time=47.9 ms
exit退出容器(退出容器后容器就停止工作)
[root@3af0e01415a4 /]# exit
exit
[root@localhost ~]#
查看已经下载的镜像
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos latest 196e0ce0c9fb 7 days ago 196.6 MB
docker.io/hello-world latest 05a3bd381fc2 9 days ago 1.84 kB
[root@localhost imagedb]# uname -a
Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost imagedb]# more /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
使用yum安装Docker(保证主机能上网)
[root@localhost imagedb]#yum install docker
查看Docker已经安装
[root@localhost imagedb]#rpm -qa | grep docker
docker-client-1.12.6-55.gitc4618fb.el7.centos.x86_64
docker-1.12.6-55.gitc4618fb.el7.centos.x86_64
docker-common-1.12.6-55.gitc4618fb.el7.centos.x86_64
启动docker
[root@localhost imagedb]# systemctl start docker.service
查看docker版本
[root@localhost ~]# docker version
Client:
Version: 1.12.6
API version: 1.24
Package version: docker-1.12.6-55.gitc4618fb.el7.centos.x86_64
Go version: go1.8.3
Git commit: c4618fb/1.12.6
Built: Thu Sep 21 22:33:52 2017
OS/Arch: linux/amd64
Server:
Version: 1.12.6
API version: 1.24
Package version: docker-1.12.6-55.gitc4618fb.el7.centos.x86_64
Go version: go1.8.3
Git commit: c4618fb/1.12.6
Built: Thu Sep 21 22:33:52 2017
OS/Arch: linux/amd64
测试运行hello word
[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ...
latest: Pulling from docker.io/library/hello-world
5b0f327be733: Pull complete
Digest: sha256:1f19634d26995c320618d94e6f29c09c6589d5df3c063287a00e6de8458f8242
Hello from Docker!
This message shows that your installation appears to be working correctly.下载并加载我们的第一个centos容器(下载时间很长)
[root@localhost ~]# docker run -i -t centos
Unable to find image 'centos:latest' locally
Trying to pull repository docker.io/library/centos ...
latest: Pulling from docker.io/library/centos
d9aaf4d82f24: Pull complete
Digest: sha256:eba772bac22c86d7d6e72421b4700c3f894ab6e35475a34014ff8de74c10872e
[root@3af0e01415a4 /]#
查看使用第一个容器
[root@3af0e01415a4 /]# more /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@3af0e01415a4 /]# hostname
3af0e01415a4
[root@3af0e01415a4 /]# more /etc/host
host.conf hostname hosts hosts.allow hosts.deny
[root@3af0e01415a4 /]# more /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2 3af0e01415a4
[root@3af0e01415a4 /]# ping www.hao123.com
PING hao123.n.shifen.com (115.239.217.167) 56(84) bytes of data.
64 bytes from 115.239.217.167 (115.239.217.167): icmp_seq=1 ttl=127 time=76.3 ms
64 bytes from 115.239.217.167 (115.239.217.167): icmp_seq=2 ttl=127 time=47.2 ms
64 bytes from 115.239.217.167 (115.239.217.167): icmp_seq=3 ttl=127 time=47.9 ms
64 bytes from 115.239.217.167 (115.239.217.167): icmp_seq=4 ttl=127 time=47.2 ms
64 bytes from 115.239.217.167 (115.239.217.167): icmp_seq=5 ttl=127 time=47.9 ms
exit退出容器(退出容器后容器就停止工作)
[root@3af0e01415a4 /]# exit
exit
[root@localhost ~]#
查看已经下载的镜像
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos latest 196e0ce0c9fb 7 days ago 196.6 MB
docker.io/hello-world latest 05a3bd381fc2 9 days ago 1.84 kB
阅读全文
0 0
- CentOS7.2下安装Docker并运行第一个容器
- 运行第一个Docker容器
- 运行第一个Docker容器
- centOs7下安装docker并搭建运行java项目环境
- Docker第一个容器
- Windows下安装QT并运行第一个程序
- Windows下安装QT并运行第一个程序
- Windows下安装QT并运行第一个程序
- Docker实践 - 安装Docker并在容器里运行tomcat
- Docker实践-安装Docker并在容器里运行tomcat
- (二)Docker run 运行第一个容器
- 运行第一个容器
- 运行第一个 docker image 并在浏览器中查看
- CentOS7下安装Docker
- CentOS7下docker安装
- CentOS7下安装Docker
- Centos7下安装Docker
- centos7下安装docker
- 大数阶乘
- 开启子线程的方法(一)
- 树莓派3vnc分辨率设置
- Android学习笔记10---View布局
- 欢迎使用CSDN-markdown编辑器
- CentOS7.2下安装Docker并运行第一个容器
- 【Java】の基础——Java语言FAQ
- 几个主流的Java连接池整理
- Swift 访问控制
- 管道和I/O重定向
- java.lang.NoClassDefFoundError: Could not initialize class XXX
- 课堂练习2: 打印当前时间。学习使用Date类和Calendar类。
- 移动webapp前端ui用哪个框架好?
- Ionic3 Android 检测并下载安装app