Ubuntu20.04云服务器-Docker配置

Ubuntu20.04云服务器-Docker配置

1. SSH服务配置

  1. 查看是否安装ssh服务

    ssh localhost
    
  2. 通过ssh连接云服务器

2. 设置存储库

  1. 更新apt包索引

    sudo apt-get update
    
  2. 安装软件包以允许apt通过HTTPS使用存储库

    sudo apt-get install ca-certificates curl gnupg
    
  3. 添加Docker的官方GPG密钥

    sudo install -m 0755 -d /etc/apt/keyrings
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
    sudo chmod a+r /etc/apt/keyrings/docker.gpg
    
  4. 使用以下命令设置存储库

    echo \
    "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
    "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
    sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    

3. Docker Engine安装

  1. 更新apt包索引

    sudo apt-get update
    
  2. 安装Docker Engine,containerd,和Docker Compose

    sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    
  3. 测试

    sudo docker run hello-world
    
  4. 开机自启动

    sudo systemctl start docker
    sudo systemctl enable docker
    

你可能感兴趣的:(服务器搭建,docker,服务器,linux)