Docker虚拟机

  • Docker安装环境要求

  ubuntu安装:https://www.cnblogs.com/senlinyang/p/8203191.html

  在安装Docker前需要确保操作系统内核版本为 3.10以上,因此需要CentOS7 ,CentOS7内核版本为3.10

  • 卸载Docker
yum remove docker \
    docker-common \
    docker-selinux \
    docker-engine
  • 安装Docker环境依赖
yum install -y yum-utils device-mapper-persistent-data lvm2
  • 配置Docker的yum源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  • 查看Docker可安装版本
yum list docker-ce --showduplicates | sort -r
  • 安装Docker
yum install docker-ce
  • 启动Docker
systemctl start docker
  • 保存镜像为文件
docker save docker.io/java > /root/java.tar.gz
  • 转换文件为镜像
docker load < /root/java.tar.gz

  • 暂停容器
docker pause java_run
  • 取消暂停
docker unpause java_run

  • docker镜像修改名字
docker tag percona/percona-xtradb-cluster pxc

  • docker创建内部网段
docker network create --subnet=172.18.0.0/24 net1
  • docker查看创建的内部网段的信息
docker network inspect net1
  • docker移除创建的内部网段
docker nerwork rm net1
docker login --username=username registry.cn-hangzhou.aliyuncs.com
  • 推送镜像到阿里云镜像仓库
docker tag nginx registry.cn-hangzhou.aliyuncs.com/pascall/nginx
docker push registry.cn-hangzhou.aliyuncs.com/pascall/nginx
  •  Docker Compose安装
yum -y install epel-release python-pip
pip install docker-compose
  •  Docker login 出错
Error response from daemon: Get https://XX/v2/: dial tcp XX:443: connect: connection refused
find / -name docker.service -type f    # 查找docker.service所在的位置
vim /etc/systemd/system/docker.service    # 添加--insecure-registry=XX


[Service]

Environment="PATH=/opt/kube/bin:/bin:/sbin:/usr/bin:/usr/sbin"

ExecStart=/opt/kube/bin/dockerd --insecure-registry=XX

ExecStartPost=/sbin/iptables -I FORWARD -s 0.0.0.0/0 -j ACCEPT

ExecReload=/bin/kill -s HUP $MAINPID

Restart=on-failure

RestartSec=5

LimitNOFILE=infinity

LimitNPROC=infinity

LimitCORE=infinity

Delegate=yes

KillMode=process

systemctl daemon-reload  # 加载配置
systemctl restart docker  # 重启docker

 

posted @ 2018-10-07 11:57  张界  阅读(245)  评论(0编辑  收藏  举报