0x00 前言
沒有太多說的,這個可能也到處都有…… 每個人的方法大概也大同小異?
主要是自己第一次接觸docker,就當作簡單的做一個記錄與總結吧。
(注意:本篇和以前的環境配置不同,遇到的問題過多,而且最終不是自己獨立完成
(故主要着眼於出現問題的記錄與過程,過程中記下來一些筆記,以及心得體會。
運氣好的同學可以直接嘗試簡單配置法
(這裏的“運氣”包括網絡穩定性與源的可聯通性):
sudo curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
0x01 自己的胡亂配置
查看當前系統版本
Linux 系統下,版本需要不小於 3.10.x
下述輸出的意思是:系統爲Linux
,名稱爲c9
,版本爲3.10.0
,64位系統
[chend@c9 ~]$ uname -a
Linux c9 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
好像確實沒有裝過docker
如果沒裝過docker的話,這麼run一下會告訴你沒裝過的
哦當然docker -h
也可以用來看看自己裝過沒
[chend@c9 ~]$ ./bin/run_docker -p 8081 -u
please install docker, see https://docs.docker.com/engine/installation
改成root權限登入
安裝的時候會需要用戶組之類的權限設置,所以需要root權限
[chend@c9 ~]$ sudo su
[root@c9 ~]#
取消selinux
不取消的話會有一些已知的衝突情況,不過我vim的時候發現它竟然本來就是
disabled
[root@c9 ~]# vim /etc/selinux/config
SELINUX=disabled
SELINUXTYPE=targeted
配置Fedora EPEL源 & hop5.in源
EPEL源必要,其它的源各位可以憑喜好添加
[root@c9 ~] yum install http://ftp.riken.jp/Linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
[root@c9 ~] cd /etc/yum.repos.d
[root@c9 yum.repos.d] wget http://www.hop5.in/yum/el6/hop5.repo
安裝
聽說大家裝完這一步就可以直接成功可以
docker -h
測試了,羨慕不已
[root@c9 yum.repos.d] yum install docker-io
more space needed on the /boot filesystem
喜聞樂見報了錯呀,可憐的我配環境的時候怎麼總是不能一下裝好呢
這次的錯誤是/boot
盤下空間不足
清理 /boot 釋放空間
網上說可以通過dpkg來找到那些過時的內核刪掉騰出空間,然而——
我沒有這個dpkg
命令……
[chend@c9 ~]$ dpkg
bash: dpkg: command not found...
尋找半天,無果,我不是Debian系統沒有dpkg呀,
還是手動跑去/boot裏剪切了一些看起來不怎麼用到的東西出來(帶.bak的)。
[chend@c9 ~]$ cd /boot
[chend@c9 boot]$ ls
config-3.10.0-693.el7.x86_64 grub2 initramfs-3.10.0-693.el7.x86_64.img.bak symvers-3.10.0-693.el7.x86_64.gz vmlinuz-3.10.0-693.el7.x86_64
efi initramfs-0-rescue-11f968f6f6144b53a5daa8495063de5e.img initramfs-3.10.0-693.el7.x86_64kdump.img System.map-3.10.0-693.el7.x86_64
grub initramfs-3.10.0-693.el7.x86_64.img initrd-plymouth.img vmlinuz-0-rescue-11f968f6f6144b53a5daa8495063de5e
[chend@c9 boot]$ ls -lht
total 169M
-rw-------. 1 root root 19M May 30 20:26 initramfs-3.10.0-693.el7.x86_64kdump.img
-rw-------. 1 root root 30M May 30 18:39 initramfs-3.10.0-693.el7.x86_64.img
drwx------. 5 root root 97 May 30 03:34 grub2
-rw-------. 1 root root 30M May 30 03:34 initramfs-3.10.0-693.el7.x86_64.img.bak
-rwxr-xr-x. 1 root root 5.7M May 30 03:32 vmlinuz-0-rescue-11f968f6f6144b53a5daa8495063de5e
-rw-------. 1 root root 67M May 30 03:32 initramfs-0-rescue-11f968f6f6144b53a5daa8495063de5e.img
-rw-r--r--. 1 root root 9.8M May 30 03:30 initrd-plymouth.img
drwxr-xr-x. 2 root root 27 May 30 03:22 grub
drwxr-xr-x. 3 root root 17 May 30 03:20 efi
-rw-r--r--. 1 root root 287K Aug 23 2017 symvers-3.10.0-693.el7.x86_64.gz
-rwxr-xr-x. 1 root root 5.7M Aug 23 2017 vmlinuz-3.10.0-693.el7.x86_64
-rw-r--r--. 1 root root 138K Aug 23 2017 config-3.10.0-693.el7.x86_64
-rw-------. 1 root root 3.1M Aug 23 2017 System.map-3.10.0-693.el7.x86_64
[chend@c9 boot]$ mv initramfs-3.10.0-693.el7.x86_64.img.bak /data/chend/
downloads/ error_detector_data/
[chend@c9 boot]$ mv initramfs-3.10.0-693.el7.x86_64.img.bak /data/chend/
downloads/ error_detector_data/
[chend@c9 boot]$ mv initramfs-3.10.0-693.el7.x86_64.img.bak /data/chend/
mv: cannot open ‘initramfs-3.10.0-693.el7.x86_64.img.bak’ for reading: Permission denied
[chend@c9 boot]$ sudo su
[root@c9 boot]# mv initramfs-3.10.0-693.el7.x86_64.img.bak /data/chend/
回頭繼續安裝docker
# yum install docker-io
# docker -h
Unit not found
哎呀終於裝起來了,那跑起來跑起來……
一波未平一波又起……Unit not found
[root@c9 boot]# sudo service docker start
Redirecting to /bin/systemctl start docker.service
Failed to start docker.service: Unit not found.
關於Unit not found的問題,查了查資料
照着試了試感覺沒有太大效果,(後記:其實是因爲docker-common
衝突)
懷疑大概是docker-io不好用,改裝普通的docker試試看?
$ sudo yum remove docker-io
$ sudo yum -y install docker
Job for docker.service failed
總之就是處於一種裝好了但就是start不起來的悲慘境地
[chend@c9 AutoDoc]$ sudo systemctl start docker.service
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
[chend@c9 AutoDoc]$ sudo systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2018-11-19 19:33:14 CST; 1min 51s ago
Docs: http://docs.docker.com
Process: 1900 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
Main PID: 1900 (code=exited, status=1/FAILURE)
Nov 19 19:33:14 c9 systemd[1]: Starting Docker Application Container Engine...
Nov 19 19:33:14 c9 dockerd-current[1900]: Error starting daemon: pid file found, ensure docker is not running or delete /var/run/docker.pid
Nov 19 19:33:14 c9 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Nov 19 19:33:14 c9 systemd[1]: Failed to start Docker Application Container Engine.
Nov 19 19:33:14 c9 systemd[1]: Unit docker.service entered failed state.
Nov 19 19:33:14 c9 systemd[1]: docker.service failed.
docker自動配置腳本
這次打算試試
get.docker.com
的自動腳本,curl你怎麼又出問題了……
配置腳本如下(curl正常的同學用這一行就足夠了):
sudo curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
[chend@c9 download]$ sudo curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
curl: (35) Encountered end of file
[chend@c9 download]$ curl --version
curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.28.4 zlib/1.2.7 libidn/1.28 libssh2/1.4.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz unix-sockets
[chend@c9 download]$ sudo curl -fsSL https://get.docker.com | bash -s docker
curl: (35) Encountered end of file
[chend@c9 download]$ curl -fsSL https://get.docker.com | bash -s docker
curl: (35) Encountered end of file
0x02 等來救援,配置由此開始
curl報錯檢查問題出處
經查證,這次curl的問題屬於
NSS is the same
的問題
https://superuser.com/questions/916077/what-is-nss-error-5961-pr-connect-reset-error
https://unix.stackexchange.com/questions/259152/curl-fails-with-ntlm-proxy
重新ssh連入,解決無法下載的問題
無計可施,於是去搬了救兵,感謝三位熱心的大神帶我逃離苦海QvQ
問了問dalao,該怎麼辦——
唉?重連ssh這是什麼情況 0.0,和重啓一個道理麼?(後面有提及)
做一個甩手掌櫃,讓dalao幫忙試試
專業的就是不一樣…… 以及實在對不起把這麼麻煩的任務交給你了QvQ
總結一下的話就是:官方源難以連通
、注意衝突依賴項
、佔用同服務進程
其它忠告
然後dalao和dalao之間開始了愉快的交流,
總結一下就是:docker官方源不穩定
、docker-compose不要用yum來裝
、scp代替直連下載
groups & newgrp docker
這次是安裝好了,那首先需要登陸一下
docker login https://xxx.xxx.com
登陸前要記得把自己的用戶加用戶組:
sudo usermod -aG docker $USER
sudo gpasswd -a chend docker
但是我把我自己加過docker用戶組了爲什麼還是不行呢?
然後請來了大師答疑解惑——
@kdr2: 主要是 newgrp 這個,一般你加了組後,得重新登錄才行
newgrp 就是不退出當前 shell 直接登進那個組,你再執行 groups 就能看到 docker 組了
0xFF 成功用上了Docker
太不容易了QvQ,記錄一下,好好看好好學,學習道路還很長……
一些常用的docker指令: https://blog.csdn.net/dongdong9223/article/details/52998375