Docker,翻译过来就是码头工人
Docker是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可抑制的容器中,然后发布到任何流行的Linux机器上,也可以实现虚拟化。容器完全使用沙盒机制,相互之间不会存在任何接口。几乎没有性能开销,可以很容易的在机器和数据中心运行。最重要的是,他们不依赖于任何语言、框架或者包装系统。
docker官网https://www.docker.com
docker中文库https://www.docker.org.cn/
安装docker前要查看centos7是否有docker假如有docker建议把它卸载在安装docker
[root@docker ~]# rpm -aq | grep docker
docker-ce-cli-20.10.21-3.el7.x86_64
docker-scan-plugin-0.21.0-3.el7.x86_64
docker-ce-rootless-extras-20.10.21-3.el7.x86_64
docker-ce-20.10.21-3.el7.x86_64
docker-compose-plugin-2.12.2-3.el7.x86_64
[root@docker ~]#
卸载docker ("\"可以批量卸载)
[root@docker ~]# yum remove docker \
docker-ce-cli-20.10.21-3.el7.x86_64\
docker-scan-plugin-0.21.0-3.el7.x86_64\
docker-ce-rootless-extras-20.10.21-3.el7.x86_64\
docker-ce-20.10.21-3.el7.x86_64\
docker-compose-plugin-2.12.2-3.el7.x86_64\
卸载完成后先配置docker的yum源,这里采用的是国内源阿里镜像站(docker.repo要放在/etc/yum.repos.d/)
[root@docker ~]# wget -O docker.repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
生成一下缓存就好
[root@docker ~]# yum makecache
开始安装docker
[root@docker ~]# yum install docker-ce -y
[root@docker ~]# yum list docker-ce --showduplicates | sort -r 可以查看可安装版本
设置开机自启、开启docker
[root@docker ~]# systemctl enable docker && systemctl start docker 开
使用pull拉取镜像
[root@docker ~]# docker images 查看现有镜像
[root@docker ~]# docker pull hello-world 拉取一个hello-world镜像
测试环境
root@docker ~]# docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
出现这样就证明你的docker环境没问题
使用docker run httpd 在后台服务
Docker ps
成功访问httpd
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)