docker搭建容器过程

这篇博客主要介绍了如何在Ubuntu Docker环境中配置国内镜像源,包括使用阿里云和清华大学的镜像源,并解决了在安装openssh-server时遇到的依赖问题。博主还分享了启动ssh、允许root登录的配置步骤,以及解决libGL.so.1库缺失和apt更新签名问题的方法。此外,针对pip安装pycuda时的错误,给出了使用清华源的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

docker 环境创建

配置apt国内镜像源

  • 备份源
cp /etc/apt/sources.list /etc/apt/sources.list_backup
vim /etc/apt/sources.list

备注:ggVG全选中,按下dd即可清除内容

编辑内容:

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

如果出现vim不可用,可使用echo

echo 'deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse' > /etc/apt/sources.list
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse' >> /etc/apt/sources.list
echo 'deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse' >> /etc/apt/sources.list
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse' >> /etc/apt/sources.list
echo 'deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse'  >> /etc/apt/sources.list
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse' >> /etc/apt/sources.list
echo 'deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse' >> /etc/apt/sources.list
echo 'deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse' >> /etc/apt/sources.list
echo 'deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse'  >> /etc/apt/sources.list
echo 'deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse' > /etc/apt/sources.list

echo 'deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse' >> /etc/apt/sources.list

echo 'deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse' >> /etc/apt/sources.list

echo 'deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse' >> /etc/apt/sources.list

echo 'deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse' >> /etc/apt/sources.list

echo 'deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse' >> /etc/apt/sources.list

echo 'deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse' >> /etc/apt/sources.list

echo 'deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse' >> /etc/apt/sources.list

echo 'deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse' >> /etc/apt/sources.list

echo 'deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse' >> /etc/apt/sources.list
  • 更新列表
apt-get update

ssh 远程连接

apt-get install openssh-server

遇到问题:

 Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:	
The following packages have unmet dependencies:
 openssh-server : Depends: openssh-client (= 1:7.6p1-4ubuntu0.4) but 1:8.2p1-4ubuntu0.1 is to be installed
                  Depends: openssh-sftp-server but it is not going to be installed
                  Recommends: libpam-systemd but it is not going to be installed
                  Recommends: ncurses-term but it is not going to be installed
                  Recommends: xauth but it is not going to be installed
                  Recommends: ssh-import-id but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

解决方案:

下载对应的客户端

apt-get install openssh-client=1:7.6p1-4ubuntu0.4
  • 启动ssh
/etc/init.d/ssh restart
  • 配置ssh远程登录
vim /etc/ssh/sshd_config

设置

PermitRootLogin yes
  • 重启ssh
/etc/init.d/ssh restart
  • 问题:ImportError: libGL.so.1: cannot open shared object file: No such file or directory
apt install libgl1-mesa-glx

问题:apt更新签名问题
Get:1 http://mirrors.aliyun.com/ubuntu bionic InRelease [242 kB]
Err:1 http://mirrors.aliyun.com/ubuntu bionic InRelease
Couldn’t create temporary file /tmp/apt.conf.51Jnba for passing config to apt-key
Get:2 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease [74.6 kB]
Err:2 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease
Couldn’t create temporary file /tmp/apt.conf.I69fNe for passing config to apt-key
Get:3 http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease [242 kB]
Err:3 http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease
Couldn’t create temporary file /tmp/apt.conf.4BqRgj for passing config to apt-key
Get:4 http://mirrors.aliyun.com/ubuntu bionic-security InRelease [88.7 kB]
Err:4 http://mirrors.aliyun.com/ubuntu bionic-security InRelease
Couldn’t create temporary file /tmp/apt.conf.F6OLEo for passing config to apt-key
Get:5 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease [88.7 kB]
Err:5 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease
Couldn’t create temporary file /tmp/apt.conf.qNuAzr for passing config to apt-key
Reading package lists… Done
W: GPG error: http://mirrors.aliyun.com/ubuntu bionic InRelease: Couldn’t create temporary file /tmp/apt.conf.51Jnba for passing config to apt-key
E: The repository ‘http://mirrors.aliyun.com/ubuntu bionic InRelease’ is not signed.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.aliyun.com/ubuntu bionic-backports InRelease: Couldn’t create temporary file /tmp/apt.conf.I69fNe for passing config to apt-key
E: The repository ‘http://mirrors.aliyun.com/ubuntu bionic-backports InRelease’ is not signed.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease: Couldn’t create temporary file /tmp/apt.conf.4BqRgj for passing config to apt-key
E: The repository ‘http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease’ is not signed.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.aliyun.com/ubuntu bionic-security InRelease: Couldn’t create temporary file /tmp/apt.conf.F6OLEo for passing config to apt-key
E: The repository ‘http://mirrors.aliyun.com/ubuntu bionic-security InRelease’ is not signed.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.aliyun.com/ubuntu bionic-updates InRelease: Couldn’t create temporary file /tmp/apt.conf.qNuAzr for passing config to apt-key
E: The repository ‘http://mirrors.aliyun.com/ubuntu bionic-updates InRelease’ is not signed.
N: Updating from such a repository can’t be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
解决方案:

chmod 777 /tmp

参考:https://bbs.huaweicloud.com/blogs/308763

问题:ERROR: Could not build wheels for pycuda which use PEP 517 and cannot be installed directly
解决方案:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pycuda --no-binary :all:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值