Centos7 docker安装实例
2023-09-11 14:17:43 时间
配置国内镜像源(提速)
REPOSITORY TAG IMAGE ID CREATED SIZE ssh-centos6 latest 670e6db182f5 5 days ago 497.1 MB docker.io/centos latest 67591570dd29 3 weeks ago 191.8 MB docker.io/centos 6 8315978ceaaa 9 weeks ago 194.6 MB [root@cloud ~]# docker run -i -t --name=centos10 ssh-centos6 /bin/bash #用镜像ssh-centos6创建容器,设置名称为centos10 [root@e308c0493046 /]#
限制容器资源
DOCKER_STORAGE_OPTIONS="--storage-opt dm.loopdatasize=2000G --storage-opt dm.loopmetadatasize=10G --storage-opt dm.fs=ext4 --storage-opt dm.basesize=20G" #dm.loopdatasize=2000G是指存放数据的数据库空间为2t,默认是100g #dm.loopmetadatasize=10G是存放Metadata数据空间为10g,默认是2g #dm.fs=ext4是指容器磁盘分区为ext4 #dm.basesize=20G是指容器根分区默认为20g,默认是10g
linux桥接网络配置
# https://docs.docker.com/installation/#installation vi /etc/sysconfig/docker #在OPTIONS=--selinux-enabled这行中修改为OPTIONS=--selinux-enabled -b=br0即让docker服务启动时使用br0网卡进行桥接
安装pipework
启动手动设置网络的容器
pipework br0 centos06 132.97.8.6/24@132.97.8.1 pipework br0 centos07 132.97.8.7/24@132.97.8.1 docker exec -i centos06 service sshd restart docker exec -i centos07 service sshd restart
# docker操作实例,图文教程 http://blog.csdn.net/wuzhilon88/article/details/41621285/
国内加速源:https://www.daocloud.io/mirror.html#accelerator-doc
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://0fc8f023.m.daocloud.io下载docker镜像
docker search centos
[root@cloud CentOS-YUM]# docker search centos INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED docker.io docker.io/centos The official build of CentOS. 2987 [OK] docker.io docker.io/jdeathe/centos-ssh CentOS-6 6.8 x86_64 / CentOS-7 7.3.1611 x8... 55 [OK] docker.io docker.io/nimmis/java-centos This is docker images of CentOS 7 with dif... 20 [OK] docker.io docker.io/consol/centos-xfce-vnc Centos container with "headless" VNC sessi... 18 [OK] docker.io docker.io/million12/centos-supervisor Base CentOS-7 with supervisord launcher, h... 12 [OK] docker.io docker.io/torusware/speedus-centos Always updated official CentOS docker imag... 8
REPOSITORY TAG IMAGE ID CREATED SIZE ssh-centos6 latest 670e6db182f5 5 days ago 497.1 MB docker.io/centos latest 67591570dd29 3 weeks ago 191.8 MB docker.io/centos 6 8315978ceaaa 9 weeks ago 194.6 MB [root@cloud ~]# docker run -i -t --name=centos10 ssh-centos6 /bin/bash #用镜像ssh-centos6创建容器,设置名称为centos10 [root@e308c0493046 /]#
限制容器资源
# CPU使用0-3总共4个核心,内存1G ,--net=none不配置网络(桥接模式是pipework设置网络) docker run -itd --net=none --name=centos07 --cpuset-cpus="0-3" -m 1024M --memory-reservation 1024M centos6-132.97.8.7-170106_2 /bin/bash
DOCKER_STORAGE_OPTIONS="--storage-opt dm.loopdatasize=2000G --storage-opt dm.loopmetadatasize=10G --storage-opt dm.fs=ext4 --storage-opt dm.basesize=20G" #dm.loopdatasize=2000G是指存放数据的数据库空间为2t,默认是100g #dm.loopmetadatasize=10G是存放Metadata数据空间为10g,默认是2g #dm.fs=ext4是指容器磁盘分区为ext4 #dm.basesize=20G是指容器根分区默认为20g,默认是10g
linux桥接网络配置
[root@localhost ~]# cd /etc/sysconfig/network-scripts/ [root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-br0 [root@localhost network-scripts]# vi ifcfg-eth0 //改成这样 DEVICE=eth0 HWADDR=00:0C:29:06:A2:35 TYPE=Ethernet UUID=34b706cc-aa46-4be3-91fc-d1f48c301f23 ONBOOT=yes BRIDGE=br0 NM_CONTROLLED=yes BOOTPROTO=static [root@localhost network-scripts]# vi ifcfg-br0 //改成这样 DEVICE=br0 TYPE=Bridge ONBOOT=yes BOOTPROTO=static IPADDR=192.168.216.131 NETMASK=255.255.255.0 GATEWAY=192.168.216.2 DNS=8.8.8.8
# https://docs.docker.com/installation/#installation vi /etc/sysconfig/docker #在OPTIONS=--selinux-enabled这行中修改为OPTIONS=--selinux-enabled -b=br0即让docker服务启动时使用br0网卡进行桥接
安装pipework
git clone https://github.com/jpetazzo/pipework cp ~/pipework/pipework /usr/local/bin/
启动手动设置网络的容器
docker run -itd --net=none --name=centos06 --cpuset-cpus="0-3" -m 1024M --memory-reservation 1024M ssh-centos6 /bin/bash使用pipework设置IP
pipework br0 centos06 132.97.8.6/24@132.97.8.1进去docker查看IP
docker attach centos06 ifconfig service sshd restart #重启ssh
pipework br0 centos06 132.97.8.6/24@132.97.8.1 pipework br0 centos07 132.97.8.7/24@132.97.8.1 docker exec -i centos06 service sshd restart docker exec -i centos07 service sshd restart
# docker操作实例,图文教程 http://blog.csdn.net/wuzhilon88/article/details/41621285/
相关文章
- linux centos7安装Docker Compose
- Centos7 系统启动docker报错 inotify add watch failed
- docker-maven-plugin:自动构建Maven多模块的Docker镜像,并推送到Docker Registry或阿里云
- 从Docker Hub和docker-registry看优秀的后端服务设计实现
- centos7 安装最新版postgresql10
- centos7安装bbr
- Opencv3.1+python2.7的CentOS7安装
- Docker环境搭建与使用:docker仓库管理的基础用法
- Centos7.x 火狐浏览器selenium的安装和使用
- Centos7上添加自定义服务文件并开机启动
- centos7作为web服务器优化
- Centos7 安装 docker-ce
- centos7安装mysql5.7.4(rpm安装版)与 MySQL5.7.4glibc版Linux安装
- Django+nginx+uwsgi部署教程(centos7+ubuntu16.4)
- centos7 安装php 多线程pthreads
- 浅析Docker数据管理-数据库容器化并持久化:数据卷概念、创建数据卷的2种方式、docker volume用法
- Centos6和Centos7下Docker的安装和使用(踩坑指南)
- Centos7 yum仓安装
- CentOS7下mongodb忘记密码后重置密码
- CentOS7下Docker Storage Pool扩容
- manjaro docker install ros2 in raspberry pi4B 使用Docker安装ROS2 (ros-humble) 并开启对Wayland的支持