美文网首页
使用github 存储dockerfile

使用github 存储dockerfile

作者: QTong | 来源:发表于2020-05-10 12:44 被阅读0次

    情景

    搭建EFK-k8s的时候发现 其他人把自己的dockerfile 放到github上 共享 这样很方便 搞了以下

    创建repo

    image.png image.png

    复制这个url


    image.png

    本地

    [root@Hello test2]# yum install git -y
    [root@Hello test2]# git clone https://github.com/Qtong121/docker_image.git
    #会在本地创建docker_image 目录
    [root@Hello test2]# ll docker_image/
    total 4
    -rw-r--r-- 1 root root 25 May 10 12:49 README.md
    #将需要上传的文件 cp到 docker_image 下
    [root@Hello test2]# ll docker_image/
    total 16
    -rw-r--r-- 1 root root  553 May 10 12:52 docker-entrypoint.sh
    -rw-r--r-- 1 root root 1233 May 10 12:52 Dockerfile
    -rw-r--r-- 1 root root  394 May 10 12:52 filebeat.yml
    -rw-r--r-- 1 root root    0 May 10 12:55 Hello.test
    -rw-r--r-- 1 root root   25 May 10 12:49 README.md
    #在 docker_image 下执行git 
    [root@Hello docker_image]# git status
    # On branch master
    # Untracked files:
    #   (use "git add <file>..." to include in what will be committed)
    #
    #       Dockerfile
    #       Hello.test
    #       docker-entrypoint.sh
    #       filebeat.yml
    nothing added to commit but untracked files present (use "git add" to track)
    [root@Hello docker_image]# git add -A
    [root@Hello docker_image]# git status
    # On branch master
    # Changes to be committed:
    #   (use "git reset HEAD <file>..." to unstage)
    #
    #       new file:   Dockerfile
    #       new file:   Hello.test
    #       new file:   docker-entrypoint.sh
    #       new file:   filebeat.yml
    #
    
    #执行commit 需要把需要提交的 文件前的注释删掉
    [root@Hello docker_image]# git commit
    [master f7ae31d]        new file:   Dockerfile  new file:   Hello.test  new file:   docker-entrypoint.sh        new file:   filebeat.yml
     4 files changed, 73 insertions(+)
     create mode 100644 Dockerfile
     create mode 100644 Hello.test
     create mode 100644 docker-entrypoint.sh
     create mode 100644 filebeat.yml
    [root@Hello docker_image]# git push
    warning: push.default is unset; its implicit value is changing in
    Git 2.0 from 'matching' to 'simple'. To squelch this message
    and maintain the current behavior after the default changes, use:
    
      git config --global push.default matching
    
    To squelch this message and adopt the new behavior now, use:
    
      git config --global push.default simple
    
    See 'git help config' and search for 'push.default' for further information.
    (the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
    'current' instead of 'simple' if you sometimes use older versions of Git)
    
    #输入 github上用户名及密码
    Username for 'https://github.com': Qtong121
    Password for 'https://Qtong121@github.com':
    Counting objects: 10, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (7/7), done.
    Writing objects: 100% (9/9), 1.70 KiB | 0 bytes/s, done.
    Total 9 (delta 1), reused 0 (delta 0)
    remote: Resolving deltas: 100% (1/1), done.
    To https://github.com/Qtong121/docker_image.git
       f983c34..7c2988f  master -> master
    

    去github上看 文件已经同步过来


    image.png

    Git 使用

    ##查看所有的分支
    git branch -r  
    ##根据远程库的某个分支创建本地分支
    git checkout -b "qtong" origin/qtong
    
    D:\NX\homework\username>rm -rf a.txt
    D:\NX\homework\username>git status
    On branch qtong
    Your branch is up to date with 'origin/qtong'.
    Changes not staged for commit:
      (use "git add/rm <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)
        (红色)    deleted:    a.txt
    no changes added to commit (use "git add" and/or "git commit -a")
    
    D:\NX\homework\username>git add .
    D:\NX\homework\username>git status
    On branch qtong
    Your branch is up to date with 'origin/qtong'.
    Changes to be committed:
      (use "git reset HEAD <file>..." to unstage)
      (绿色)      deleted:    a.txt
    D:\NX\homework\username>git commit -a -m"111"
    [qtong fee4cfc] 111
     1 file changed, 1 deletion(-)
     delete mode 100644 username/a.txt
    D:\NX\homework\username>git push
    
    
    

    相关文章

      网友评论

          本文标题:使用github 存储dockerfile

          本文链接:https://www.haomeiwen.com/subject/anfjnhtx.html