Docker學習 - 安裝
https://docs.docker.com/compose/gettingstarted/
1.根據機器架構下載
[centos@centos7 ~]$ uname -s
Linux
主機名
uname -n
[centos@centos7 ~]$ uname -m
x86_64
https://github.com/docker/compose/releases/
2.授權
sudo chmod +x /usr/local/bin/docker-compose
運行
docker-compose --version
3.安装 Docker CE
# 安装工具包从而可以让我们在 yum 中添加别的仓储源 sudo yum install -y yum-utils \ device-mapper-persistent-data \ lvm2 # 设置 docker ce 的稳定库地址 sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo # 安装 docker ce sudo yum install docker-ce docker-ce-cli containerd.io
4.運行 Docker
[centos@centos7 usr]$ /usr/bin/docker -v
Docker version 20.10.8, build 3967b7d
[centos@centos7 ~]$ docker info
Docker Root Dir: /var/lib/docker
5.启动 docker
systemctl start docker
# 启动 Docker 服务并允许开机自启 sudo systemctl start docker # 查看当前 dokcer 的运行情况 sudo systemctl status docker
將用戶加入docker組
查看/var/run/docker.sock權限
ps -l
將用戶加入docker組
sudo gpasswd -a centos docker
更新docker組
newgrp docker
docker ps #测试docker命令是否可以使用sudo正常使用
docker version
docker info
6.運行
[centos@centos7 run]$ docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
service docker restart
查看docker狀態
systemctl status docker
7.daemon配置文件
sudo chmod +777 /etc/docker/daemon.json
sudo chmod +777 -R /var/lib/docker
cat /etc/docker/daemon.json
8.docker run python
docker run -it python:3.7 bash
9.Clean up space used by Docker
docker system prune -a
docker volumes prune