docker环境配置

本文详细介绍了如何在虚拟机Linux和树莓派上配置Docker环境,包括卸载旧版Docker、安装Docker Engine、设置国内镜像源以及赋予用户权限。此外,还提到了检查用户组和使用基本Linux命令的操作。
摘要由CSDN通过智能技术生成

1. 虚拟机linux环境

  1. 下载VNware
    https://zhuanlan.zhihu.com/p/41940739
    https://zhuanlan.zhihu.com/p/141033713
    参考此2篇文章安装
  2. 安装Ubuntu。
  3. 安装docker
    https://www.runoob.com/docker/ubuntu-docker-install.html

2. 树莓派linux

前面在虚拟机上搞得,不是很好操作。下面开始在树莓派上搞。

  1. 开启树莓派ssh, raspi-config。 facing-setting, ssh。
  2. 按照docker官网教程安装docker。https://docs.docker.com/engine/install/debian/
  3. 树莓派配置国内源。https://zhuanlan.zhihu.com/p/98079246
  4. docker使用国内源。https://www.runoob.com/docker/ubuntu-docker-install.html
    树莓派版本的docker切换源。https://blog.csdn.net/qq_29753285/article/details/95094788

2.1卸载docker

sudo apt-get remove docker docker-engine docker.io containerd runc

1, 更新linux

 sudo apt-get update
 sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

2,Add Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
这里改阿里源
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/debian/gpg | sudo apt-key add -

3.Use the following command to set up the stable repository. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below. Learn about nightly and test channels.

echo \
  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  修改后的
sudo echo \
  "deb [arch=armhf] http://mirrors.aliyun.com/docker-ce/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

注意这里的armhf。https://www.codenong.com/37790029/

3. Install Docker Engine

1.Update

 sudo apt-get update
 sudo apt-get install docker-ce docker-ce-cli containerd.io

二、使用国内镜像
修改/etc/docker/daemon.json,添加如下配置:

 sudo vi /etc/docker/daemon.json

{
   "registry-mirrors": ["https://registry.docker-cn.com","http://hub-mirror.c.163.com"]
}

然后执行命令systemctl restart docker重启docker

4. 测试

1.输出version:
docker --version
2. docker run hello-world 权限不足
添加权限:https://blog.csdn.net/weixin_47758362/article/details/108050348

sudo gpasswd -a username docker #将普通用户username加入到docker组 

环境配置完成。

linux几个命令:

usermod -a -G sudo test
usermod -a -G adm test
上面这个代码的意思是,把test用户添加到sudo和admin用户组里面。这里要注意的是系统里面的admin的用户组的名字是"adm"。
groups test
上面这个命令的意思是检查test所在的用户组

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值