Docker搭建私有仓库

  • 公有云:比如百度云, dockerhub
  • 私有云:比如搭建到某个内网, docker
  • 搭建私有仓库:
下载一个镜像
docker默认使用的是dockerhub
docker仓库服务器就是docker注册服务器

//注意docker pull 和dockerspush的区别,如将docker镜像上传到仓库
docker push

1.下载docker注册服务器镜像
docker pull registry:lastes

2.以后台的方式进行运行注册服务器
docker run -d -p 5000:5000 --name server -registry -v /tmp/registry:/tmp/registry registry
//命令执行后将镜像放到了以下目录
/tmp/registry/

3.上传镜像
docker images
//为镜像创建标签
docker tag centos:1.2 losthost:5000/centos:1.2
//将镜像上传到私有仓库
docker psuh losthost:5000/centos:1.2
docker images

4.其他机器下载
下载镜像,从其他一台机器下载私有仓库的镜像
docker pull 192.168.x.xxx:5000/centos:1.2
docker images

  • shell基本语法
//查看系统中的bash解释器
cat /etc/shells
  • 基本命令:
//重定向的输出
echo "hello" > a.txt
ls
cat a.txt

//重定向的输出
cat <a.txt

//可以把任何文件放进这个垃圾箱
echo hello world > /dev/null

  • 管道(连接):
//对目录占用空间进行统计大小
ls | du -sh

//过滤信息
ifconfig -a | grep "ether"

//$是变量
ifconfig -a | grep "ether" | awk '{print $2}'
//$引用变量
name = zhangsan
//打印name
echo $name

//$()可以连接多条命令一般用来写脚本, ``适合包含少量命令
//$后面是一条命令,将命令的结果赋值给变量
dir=$(pwd)
echo dir

//结果相同的写法
dir=`pwd`
echo $dir

//起到连接作用
make && make install
echo 123 && echo 1234565
lssa && echo 123// 执行失败

同一台主机虚拟成多台主机
vim /etc/hosts/
ssh-keygen
ssh-copy-id node1
ssh node1就可以直接连接
for i in node{1..3};do ssh node$1 'hostname'; done
三个主机

mkdir shell
ls
cd shell/
ls
vim while.sh
//eq le mo 
#!/bin/bash
a=1
while [ $a -eq 5]
do
echo "hello"
a=$((a + 1))
done

vim if.sh


!/bin/bash
reads -p "please input a number" a
if [$a==5]
then
echo "a==5"
else
echo "a!=5"
fi

//不需要 vim的编辑
cd shell/
cat > hello.txt <<EOF
>no.1
>no.1
>no.3
>EOF
ls
cat hello.txt