Docker下创建Centos系统
Docker已经为我们提供了centos系统镜像,因此我们可以通过命令来查询相关镜像信息。当然你也可以自己定制镜像。
查询centos镜像信息:
[[email protected] ~]# docker search centos
以下是查询centos信息的结果:
我们可以使用最近提供的centos镜像。
[[email protected] exec]# docker pull centos
[[email protected] exec]# docker images
已经可以看到镜像信息:
启动docker容器:
docker run -v /data/tmp/:/tmp -it --name=centos-cloudboot -d centos /bin/bash
这里我们通过-v参数实现主机/data/tmp目录与容器centos/tmp目录的映射,以此来实现主机与centos之间方便互传文件;-d 参数选择相关镜像;-i 交互式操作;-t 终端;--name 指定容器名称;-d 镜像名;/bin/bash 交互式终端。
附:赋予docker容器特权模式,并且容器中可以执行service命令docker run -v /data/tmp/:/tmp -it --privileged=true --name=centos-mysql -d centos /usr/sbin/init
查看容器:
[[email protected] exec]# docker ps
进入docker下centos系统:
[[email protected] exec]# docker exec -it a0b1b6a3d5b3 bash
[[email protected] yum.repos.d]# cat /etc/os-release
转载于:https://blog.51cto.com/bovin/1972002