今天自行架設了一台 NextCloud,使用的是 docker 方式來搭建,過程很快大概一個小時就建立好了,將架設的過程記錄一下,大家可以參考看看。
NextCloud 主機環境
- OS:CentOS
- CPU:雙核
- RAM:8G
- HDD:800G
程式筆記本,寫下來就記得了。
最近在安裝 Docker 時發現,怎麼使用 yum install -y docker
安裝的 Docker 版本都會是 Docker version 1.13.1 (官網),這版本已經是 2017年2月8日,好舊的版本,目前官方都已經更新到 Docker version 20.10.3 (官網) 2021年2月1日。
整理了一下,如何將舊版本強制更新至最新版流程。
使用的OS為 CentOS7
可使用以下指令確認,並記錄目前已安裝的套件docker -v
or docker version
rpm -qa | grep docker
[root@web ~]# docker -v Docker version 1.13.1, build 0be3e21/1.13.1 [root@web ~]# rpm -qa | grep docker docker-common-1.13.1-203.git0be3e21.el7.centos.x86_64 docker-client-1.13.1-203.git0be3e21.el7.centos.x86_64 docker-1.13.1-203.git0be3e21.el7.centos.x86_64
雖然我們可以透過 docker logs <container name> 去看 container 裡的日誌,但是如果 docker 服務壞了,我們要去哪裡找呢?
Docker 日誌 一般是交给了 Upstart(Ubuntu 14.04) 或者 systemd (CentOS 7, Ubuntu 16.04)。前者一般位於 /var/log/upstart/docker.log 下,後者一般通過 jounarlctl -u docker 来讀取。不同系统的位置都不一樣,可以參考下表:
OS系統 | 日誌路徑 |
Ubuntu(14.04) | /var/log/upstart/docker.log |
Ubuntu(16.04) | journalctl -u docker.service |
CentOS | journalctl -u docker.service |
Fedora | journalctl -u docker.service |
參考docker registry 來源:https://hub.docker.com/_/registry
環境:CentOS 7
Docker-Registry主機上執行指令:docker run -d -p 5000:5000 -v /home/docker-registry/storage:/var/lib/registry --name registry registry:latest
[root@Docker-Registry ~]# docker run -d -p 5000:5000 -v /home/docker-registry/storage:/var/lib/registry --name registry registry:latest Unable to find image 'registry:latest' locally Trying to pull repository docker.io/library/registry ... latest: Pulling from docker.io/library/registry cbdbe7a5bc2a: Pull complete 47112e65547d: Pull complete 46bcb632e506: Pull complete c1cc712bcecd: Pull complete 3db6272dcbfa: Pull complete Digest: sha256:8be26f81ffea54106bae012c6f349df70f4d5e7e2ec01b143c46e2c03b9e551d Status: Downloaded newer image for docker.io/registry:latest 4c8c0b3e0981716be24d49c360a46c38ccdeaafd9f52ee541a250e8154f17941
指令說明:
-d 背景執行
-p 5000:5000 使用5000 port
-v 將本地的 /home/docker-registry/storage 關連至 /var/lib/registry
–name docker令名,可自定
registry:latest 取得docker hub 上 registry 最新的版本
建立完成後,可執行 docker ps -a
查看是否正常運行
[root@Docker-Registry ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4c8c0b3e0981 registry:latest "/entrypoint.sh /e..." 18 minutes ago Up 18 minutes 0.0.0.0:5000->5000/tcp registry
目前 Hub Docker (https://hub.docker.com/) 上有需多 images 可以 pull 下來,這樣一來可以省去你去放光碟片,一步一步安裝你要的軟體。
centos(為提供者):latest(為最新版號,你也可以指定你要的版本)
[root@localhost]# docker pull centos Using default tag: latest latest: Pulling from library/centos 8a29a15cefae: Pull complete Digest: sha256:fe8d824220415eed5477b63addf40fb06c3b049404242b31982106ac204f6700 Status: Downloaded newer image for centos:latest
因 docker-compose 的版本不同,或是自己的 version 版本問題,請在執行 curl 之前先到官網看一下新的版本 https://docs.docker.com/compose/install/
如何在AWS EC2 上安裝 Docker 環境
[root@localhost ~]# yum install docker Loaded plugins: priorities, update-motd, upgrade-helper Resolving Dependencies --> Running transaction check ---> Package docker.x86_64 0:18.09.9ce-2.52.amzn1 will be installed --> Processing Dependency: runc = 1.0.0 for package: docker-18.09.9ce-2.52.amzn1.x86_64 --> Processing Dependency: containerd = 1.2.6 for package: docker-18.09.9ce-2.52.amzn1.x86_64 --> Processing Dependency: xfsprogs for package: docker-18.09.9ce-2.52.amzn1.x86_64 --> Processing Dependency: pigz for package: docker-18.09.9ce-2.52.amzn1.x86_64 --> Processing Dependency: libseccomp.so.2()(64bit) for package: docker-18.09.9ce-2.52.amzn1.x86_64 --> Running transaction check ---> Package containerd.x86_64 0:1.2.6-1.2.amzn1 will be installed ---> Package libseccomp.x86_64 0:2.3.1-2.4.amzn1 will be installed ---> Package pigz.x86_64 0:2.3.3-1.6.amzn1 will be installed ---> Package runc.x86_64 0:1.0.0-0.1.20190510.git2b18fe1.0.amzn1 will be installed ---> Package xfsprogs.x86_64 0:4.5.0-18.23.amzn1 will be installed --> Finished Dependency Resolution Dependencies Resolved ==================================================================================== Package Arch Version Repository Size ==================================================================================== Installing: docker x86_64 18.09.9ce-2.52.amzn1 amzn-updates 35 M Installing for dependencies: containerd x86_64 1.2.6-1.2.amzn1 amzn-updates 26 M libseccomp x86_64 2.3.1-2.4.amzn1 amzn-main 79 k pigz x86_64 2.3.3-1.6.amzn1 amzn-main 71 k runc x86_64 1.0.0-0.1.20190510.git2b18fe1.0.amzn1 amzn-updates 2.3 M xfsprogs x86_64 4.5.0-18.23.amzn1 amzn-updates 1.7 M Transaction Summary ==================================================================================== Install 1 Package (+5 Dependent packages) Total download size: 65 M Installed size: 223 M Is this ok [y/d/N]: y Downloading packages: (1/6): libseccomp-2.3.1-2.4.amzn1.x86_64.rpm | 79 kB 00:00:00 (2/6): pigz-2.3.3-1.6.amzn1.x86_64.rpm | 71 kB 00:00:00 (3/6): runc-1.0.0-0.1.20190510.git2b18fe1.0.amzn1.x86_64.rpm | 2.3 MB 00:00:01 (4/6): containerd-1.2.6-1.2.amzn1.x86_64.rpm | 26 MB 00:00:03 (5/6): xfsprogs-4.5.0-18.23.amzn1.x86_64.rpm | 1.7 MB 00:00:00 (6/6): docker-18.09.9ce-2.52.amzn1.x86_64.rpm | 35 MB 00:00:05 ------------------------------------------------------------------------------------ Total 11 MB/s | 65 MB 00:00:05 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : libseccomp-2.3.1-2.4.amzn1.x86_64 1/6 Installing : runc-1.0.0-0.1.20190510.git2b18fe1.0.amzn1.x86_64 2/6 Installing : containerd-1.2.6-1.2.amzn1.x86_64 3/6 Installing : pigz-2.3.3-1.6.amzn1.x86_64 4/6 Installing : xfsprogs-4.5.0-18.23.amzn1.x86_64 5/6 Installing : docker-18.09.9ce-2.52.amzn1.x86_64 6/6 Verifying : docker-18.09.9ce-2.52.amzn1.x86_64 1/6 Verifying : xfsprogs-4.5.0-18.23.amzn1.x86_64 2/6 Verifying : libseccomp-2.3.1-2.4.amzn1.x86_64 3/6 Verifying : containerd-1.2.6-1.2.amzn1.x86_64 4/6 Verifying : runc-1.0.0-0.1.20190510.git2b18fe1.0.amzn1.x86_64 5/6 Verifying : pigz-2.3.3-1.6.amzn1.x86_64 6/6 Installed: docker.x86_64 0:18.09.9ce-2.52.amzn1 Dependency Installed: containerd.x86_64 0:1.2.6-1.2.amzn1 libseccomp.x86_64 0:2.3.1-2.4.amzn1 pigz.x86_64 0:2.3.3-1.6.amzn1 runc.x86_64 0:1.0.0-0.1.20190510.git2b18fe1.0.amzn1 xfsprogs.x86_64 0:4.5.0-18.23.amzn1 Complete!