Docker
前置作業
如果需要自動完成功能必須安裝bash-completion
1
| sudo yum install -y yum-utils device-mapper-persistent-data lvm2 bash-completion
|
安裝
安裝 Docker 最新版本
1
| sudo curl -fsSL https://get.docker.com/ | sh
|
設定使用權限
1
| sudo usermod -aG docker $USER
|
開啟服務
1
| sudo systemctl enable --now docker
|
(Suggest) 設定 Log rotate
1 2 3 4 5 6 7 8 9
| sudo cat << EOF > /etc/docker/daemon.json { "log-driver": "json-file", "log-opts": { "max-size": "10m", "max-file": "10" } } EOF
|
(Optional) 自動完成功能
1
| sudo curl https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker -o /etc/bash_completion.d/docker.sh
|
Troubleshooting
Requires containerd.io
在CentOS 8
上需要另外更新 containerd
1
| sudo dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
|
Remove PodMan
在CentOS
上可能預設安裝了PodMan
,必須將它移除
1
| sudo dnf remove podman -y
|
Docker-compose
安裝
1 2 3 4 5 6 7
| echo alias docker-compose="'"'docker run --rm \ -v /var/run/docker.sock:/var/run/docker.sock \ -v "$PWD:$PWD" \ -w="$PWD" \ docker/compose:1.24.0'"'" >> ~/.bashrc
source ~/.bashrc
|