安装docker CE for CentOS

Posted Fatt

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装docker CE for CentOS相关的知识,希望对你有一定的参考价值。

Uninstall old versions

  sudo yum remove docker 
                docker-client
                docker-client-latest
                docker-common
                docker-latest
                docker-latest-logrotate
                docker-logrotate
                docker-engine

SET UP THE REPOSITORY

  sudo yum install -y  yum-utils device-mapper-persistent-data lvm2
?
sudo yum-config-manager --add-repo   https://download.docker.com/linux/centos/docker-ce.repo
?

Optional

  sudo yum-config-manager --enable docker-ce-edge
sudo yum-config-manager --enable docker-ce-test
#可以关闭
sudo yum-config-manager --disable docker-ce-edge

INSTALL DOCKER CE

1、common install

  sudo yum install -y docker-ce

2、to install specific version

  yum list docker-ce --showduplicates | sort -r
?
#docker-ce.x86_64           18.09.0.ce-1.el7.centos           docker-ce-stablebash
?
sudo yum install docker-ce-<VERSION STRING>

3、start and verify

  sudo systemctl start docker
sudo docker run hello-world

Install using the convenience script

  $ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
?
<output truncated>
?
sudo usermod -aG docker your-user

Uninstall Docker CE

  sudo yum remove docker-ce
sudo rm -rf /var/lib/docker

Test Docker version

  docker --version
sudo docker info

Test Docker installation

  sudo docker run hello-world
sudo docker image ls
sudo docker container ls --all

Recap and cheat sheet

  ## List Docker CLI commands
docker
docker container --help
?
## Display Docker version and info
docker --version
docker version
docker info
?
## Execute Docker image
docker run hello-world
?
## List Docker images
docker image ls
?
## List Docker containers (running, all, all in quiet mode)
docker container ls
docker container ls --all
docker container ls -aq

客户端配置

1、证书方式

  sudo mkdir -p /etc/docker/certs.d/192.192.49.87
sudo cp /var/docker-data/certs/domain.crt /etc/docker/certs.d/192.192.49.87/ca.crt
?
#可能需要OS级信任
sudo cp /etc/dockercerts/domain.crt /etc/pki/ca-trust/source/anchors/192.192.49.87.crt
sudo update-ca-trust
?

2、http方式

  #或者关闭安全
sudo cat << EOF > /etc/docker/daemon.json
{
 "insecure-registries" : ["192.192.49.87"]
}
EOF
?
sudo systemctl restart docker

docker-compose配置

安装

  sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
?
sudo chmod +x /usr/local/bin/docker-compose
?
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version

END
































































以上是关于安装docker CE for CentOS的主要内容,如果未能解决你的问题,请参考以下文章

centOS7安装Docker CE

docker-ce如何在centos上安装

CentOS7 Docker-ce 安装(阿里源)

centos7安装docker-ce

Centos7安装Docker CE

centos 8 docker-ce 安装