centos 安装docker CE

centos 安装docker CE

0. 参考

1. 安装需要的包

sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2

2. 添加仓库

sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

3. 安装docker

sudo yum install docker-ce docker-ce-cli containerd.io

4. 启动

sudo systemctl start docker

5. 将当前用户加入docker组

groupadd docker 
sudo gpasswd -a $USER docker 
newgrp docker

解决使用docker命令时提示
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json": dial unix /var/run/docker.sock: connect: permission denied

centos 安装docker compose

1. 下载docker compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

2. 更改执行权限

sudo chmod +x /usr/local/bin/docker-compose

# centos7需要将 /usr/local/bin/添加到/etc/profile文件最后
vim /etc/profile
export PATH=$PATH:/usr/local/sbin:/usr/local/bin

source /etc/profile

3. 查询版本

docker-compose --version

你可能感兴趣的:(docker,centos,容器)