在SUSE SLE 12上安装docker(二进制安装docker)

对于13.2之后的版本,因为docker已经被添加到了suse仓库中,直接使用sudo zypper install docker即可。
但是当前手上的机器是suse12.3,不支持以安装包的方式安装docker。本文记录在该环境上(SUSE SLE 12)以二进制方式安装docker的过程。

  1. 下载wget https://download.docker.com/linux/static/stable/x86_64/docker-17.03.2-ce.tgz
  2. 解压tar xzvf docker-17.03.2-ce.tgz
  3. sudo cp docker/* /usr/bin/ 移动到执行目录下
  4. 创建docker用户组
sudo groupadd docker
  1. 应用用户加入docker用户组
sudo usermod -aG docker ${USER}
  1. 启动docker daemon sudo dockerd
    这一步遇到报错如下:
INFO[0000] libcontainerd: new containerd process, pid: 19581
WARN[0000] containerd: low RLIMIT_NOFILE changing to max  current=1024 max=4096
ERRO[0001] 'overlay' not found as a supported filesystem on this host. Please ensure kernel is new enough and has overlay support loaded.
ERRO[0001] 'overlay' not found as a supported filesystem on this host. Please ensure kernel is new enough and has overlay support loaded.
ERRO[0001] devmapper: Udev sync is not supported. This will lead to data loss and unexpected behavior. Install a dynamic binary to use devicemapper or select a different storage driver. For more information, see https://docs.docker.com/engine/reference/commandline/dockerd/#storage-driver-options
INFO[0001] Graph migration to content-addressability took 0.00 seconds
WARN[0001] Your kernel does not support swap memory limit
WARN[0001] Your kernel does not support kernel memory limit
INFO[0001] Loading containers: start.
WARN[0001] Running modprobe bridge br_netfilter failed with message: , error: exec: "modprobe": executable file not found in $PATH
WARN[0001] Running modprobe nf_nat failed with message: ``, error: exec: "modprobe": executable file not found in $PATH
WARN[0001] Running modprobe xt_conntrack failed with message: ``, error: exec: "modprobe": executable file not found in $PATH
INFO[0001] Firewalld running: false
Error starting daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain: Iptables not found

错误提示找不到Iptables

解决方案:
修改~/.bashrc/usr/sbin加入环境变量

export PATH="/usr/sbin/:$PATH"
  1. 再次启动docker daemon sudo dockerd成功
# INFO[0000] libcontainerd: new containerd process, pid: 21413
WARN[0000] containerd: low RLIMIT_NOFILE changing to max  current=1024 max=4096
INFO[0001] Graph migration to content-addressability took 0.00 seconds
WARN[0001] Your kernel does not support swap memory limit
WARN[0001] Your kernel does not support kernel memory limit
INFO[0001] Loading containers: start.
INFO[0001] Firewalld running: false
INFO[0001] Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address
INFO[0001] Loading containers: done.
INFO[0001] Daemon has completed initialization
INFO[0001] Docker daemon                                 commit=f5ec1e2 graphdriver=overlay2 version=17.03.2-ce
INFO[0001] API listen on /var/run/docker.sock
  1. 运行docker run hello-world进行测试
ERRO[0044] Handler for POST /v1.27/containers/create returned error: No such image: hello-world:latest
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
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/

另:在其他机器上升级docker版本之后执行sudo dockerd出现如下报错:

INFO[0000] libcontainerd: new containerd process, pid: 11582
WARN[0000] containerd: low RLIMIT_NOFILE changing to max  current=1024 max=4096
ERRO[0001] devmapper: Udev sync is not supported. This will lead to data loss and unexpected behavior. Install a dynamic binary to use devicemapper or select a different storage driver. For more information, see https://docs.docker.com/engine/reference/commandline/dockerd/#storage-driver-options
ERRO[0001] [graphdriver] prior storage driver devicemapper failed: driver not supported
Error starting daemon: error initializing graphdriver: driver not supported

解决方法:

sudo mv /var/lib/docker /var/lib/docker.old  

再次启动docker daemon sudo dockerd
服务可以正常启动。 原因是:/var/lib/docker 目录有旧版本的遗留文件,版本升级后需要删除。
这时根据需要将刚刚复制备份的文件删除即可。rm -rf /var/lib/docker.old

Install Docker CE from binaries

你可能感兴趣的:(在SUSE SLE 12上安装docker(二进制安装docker))