1. 程式人生 > 其它 >Leetcode No.35 Search Insert Position(c++實現)

Leetcode No.35 Search Insert Position(c++實現)

準備工作

系統要求

Docker 支援 64 位版本 CentOS 7/8,並且要求核心版本不低於 3.10。 CentOS 7 滿足最低核心的要求,但由於核心版本比較低,部分功能(如 overlay2 儲存層驅動)無法使用,並且部分功能可能不太穩定。

解除安裝舊版本

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

使用 yum 安裝

執行以下命令安裝依賴包:

sudo yum install -y yum-utils

鑑於國內網路問題,強烈建議使用國內源,官方源請在註釋中檢視。

sudo yum-config-manager \
    --add-repo \
    https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

sudo sed -i 's/download.docker.com/mirrors.aliyun.com\/docker-ce/g' /etc/yum.repos.d/docker-ce.repo

# 官方源
# sudo yum-config-manager \
#     --add-repo \
#     https://download.docker.com/linux/centos/docker-ce.repo

安裝Docker

sudo yum install docker-ce docker-ce-cli containerd.io

啟動Docker

sudo systemctl enable docker
sudo systemctl start docker

測試是否安裝正確

輸入:

docker run --rm hello-world

看見如下內容則成功安裝!

docker run --rm hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

新增核心引數

如果在 CentOS 使用 Docker 看到下面的這些警告資訊:

WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled

請新增核心配置引數以啟用這些功能:

sudo tee -a /etc/sysctl.conf <<-EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF

然後重新載入 sysctl.conf 即可

sudo sysctl -p