离线安装docker

下载安装包

如果服务器无法联网从Docker仓库安装docker,那可以下载.rpm文件后手动解压并安装。

  1. 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.

  1. 安装Docker CE,改变路径到docker安装包目录下。

  2. 安装Docker

$ sudo rpm-ivh /path/to/package.rpm

现在docker已经安装了,但还未启动。docker group已创建,但还没有用户添加到docker group里

  1. 启动Docker.
$ sudo systemctl start docker
  1. 启动一个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

推荐阅读更多精彩内容