Git

fork出来的仓库同步upstream

  1. 在 fork 的代码库中添加上游代码库的 remote 源
git remote add upstream git@github.com:789/456.git
  1. 获取原始仓库分支和对应的提交
git fetch upstream
  1. 在本地实现与upstream的同步
git rebase upstream/master
  1. 推送自己的本地仓库到自己的远程仓库
git push

Push tags to remote

  • git push --tags <repo-name> All refs under refs/tags are pushed, in addition to refspecs explicitly listed on the command line.

Delete remote tags/branch

# more expressively, use the --delete option (or -d if your git version is older than 1.8.0)
git push --delete origin tagname

or

# You just need to push an 'empty' reference to the remote tag name:
$ git push origin :tagname

查看外网出口ip

$ curl ifconfig.me

Upgrade docker on centos 7.4

sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux  docker-engine-selinux docker-engine
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce


sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker

: when run docker build get error: is not a valid repository/tag

Maybe the rease as below:

  1. The tag name not allowing uppercase characters.
  2. current docker version not support multiple stages build.

Docker ADD vs COPY

ADD

  1. ADD can also copy files from a URL
  2. ADD it copies compressed files, automatically extracting the content in the given destination.

Notes: this feature only applies to locally stored compressed files/directories. You CAN NOT download and extract a compressed file/direcotry from a URL.

Notes: The recognized compression formats include identity, gzip, bzip, and xz.

COPY

COPY can be used only for locally stored files.

Which to Use (Best Pratices)

Docker’s official documentation notes that COPY should always be the go-to instruction as it is more transparent than ADD.

The Docker team also strongly discourages using ADD to download and copy a package from a URL. Instead, it’s safer and more efficient to use wget or curl within a RUN command. By doing so, you avoid creating an additional image layer and save space.

Let’s say you want to download a compressed package from a URL, extract the content, and clean up the archive.

Instead of using ADD and running the following command:

ADD http://source.file/package.file.tar.gz /temp
RUN tar -xjf /temp/package.file.tar.gz \
  && make -C /tmp/package.file \
  && rm /tmp/ package.file.tar.gz

You should use:

RUN curl http://source.file/package.file.tar.gz \
  | tar -xjC /tmp/ package.file.tar.gz \
  && make -C /tmp/ package.file.tar.gz

Docker ENTRYPOINT vs CMD

In short, CMD defines default commands and/or parameters for a container. CMD is an instruction that is best to use if you need a default command which users can easily override. If a Dockerfile has multiple CMDs, it only applies the instructions from the last one.

On the other hand, ENTRYPOINT is preferred when you want to define a container with a specific executable. You cannot override an ENTRYPOINT when starting a container unless you add the –entrypoint flag.

Combine ENTRYPOINT with CMD if you need a container with a specified executable and a default parameter that can be modified easily. For example, when containerizing an application use ENTRYPOINT and CMD to set environment-specific variables.

CMD 定义默认的命令或是容器的参数, 如果你需要一个默认的指令,而用户可以很容易地覆盖这个指令,那么 CMD 是最好使用的。 如果一个 Dockerfile 有多个 CMD, 最后一个会生效。

另外, 当你想定义一个指定的可执行命令时, ENTRYPOINT 是最好的选择。 当启动容器时,你不能覆盖 ENTRYPOINT,除非你添加 --entrypoint 的参数.

如果你需要一个容器包含指定的可执行命令和一个很容易被修改的默认参数,则需要结合使用 ENTRYPOINTCMD。 比如,一个容器化的应用使用 ENTRYPOINT 定义可执行命令,通过 CMD 设置环境指定的变量。

Nginx Localtion ends with the slash character

If a location is defined by a prefix string that ends with the slash character, and requests are processed by one of proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass, memcached_pass, or grpc_pass, then the special processing is performed. In response to a request with URI equal to this string, but without the trailing slash, a permanent redirect with the code 301 will be returned to the requested URI with the slash appended. If this is not desired, an exact match of the URI and location could be defined like this:

location /user/ {
    proxy_pass http://user.example.com;
}

location = /user {
    proxy_pass http://login.example.com;
}

Refer to: https://nginx.org/en/docs/http/ngx_http_core_module.html#location

Vim