下載安裝包
如果服務(wù)器無法聯(lián)網(wǎng)從Docker倉庫安裝docker,那可以下載.rpm文件后手動解壓并安裝。
- 到https://download.docker.com/linux/centos/7/x86_64/stable/Packages/下載需要的docker版本的.rpm文件
Note: To install an edge package, change the word stable in the above URL to edge.Learn about stable and edge channels.
安裝Docker CE,改變路徑到docker安裝包目錄下。
安裝Docker
$ sudo rpm-ivh /path/to/package.rpm
現(xiàn)在docker已經(jīng)安裝了,但還未啟動。docker group已創(chuàng)建,但還沒有用戶添加到docker group里
- 啟動Docker.
$ sudo systemctl start docker
- 啟動一個hello-world鏡像來確認docker已安裝成功。
$ sudo docker run hello-world
這個命令下載了啟動了一個容器并在其中啟動了hello-world測試鏡像。當容器啟動后,會打印出一些信息,之后退出。
Docker CE is installed and running. You need to use sudo to run Docker commands. Continue to Post-installation steps for Linux to allow non-privileged users to run Docker commands and for other optional configuration steps.
UPGRADE DOCKER CE
To upgrade Docker CE, download the newer package file and repeat the installation procedure, using yum -y upgrade instead of yum -y install, and pointing to the new file.
注意:
error: Failed dependencies:
container-selinux >= 2.9 is needed by docker-ce-18.06.1.ce-3.el7.x86_64
[root@gxfw dockerInstall]# rpm -ivh container-selinux-2.9-4.el7.noarch.rpm
warning: container-selinux-2.9-4.el7.noarch.rpm: Header V3 RSA/SHA256 Signature,
需要安裝依賴包 container-selinux-2.9-4.el7.noarch.rpm。
開啟docker管理端口
mkdir /etc/systemd/system/docker.service.d
cat > /etc/systemd/system/docker.service.d/tcp.conf <<EOF
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375
EOF
systemctl daemon-reload
systemctl restart docker