Docker 随笔记

Docker使用过程中的问题记录,不定时更新。

目录

2. 搜索、安装Ubuntu

3. Docker中Ubuntu安装软件,查看IP

4. 在Docker中的ubuntu中安装 Python3 和 Pip

5. windows 的 Docker 中安装的 Ubuntu 无法修改文件权限

6. docker 容器内以非root登陆的方法

7. sh: 1: rsync: not found


1. Docker中,上下左右按键使用出错,^[[A^[[B^[[C^[[D

解决:进入之后,先在命令行中输入“bash

参考:Docker中,上下左右按键使用出错,^[[A^[[B^[[C^[[D - 猫和大叔 - 博客园

2. 搜索、安装Ubuntu

在 cmd 里面搜索ubuntu:docker search ubuntu

指定版本: 

docker search ubuntu:20.04

下拉镜像、安装:

docker pull ubuntu:20.04

参考:https://zhuanlan.zhihu.com/p/302961875

3. Docker中Ubuntu安装软件,查看IP

由于docker进行Ubuntu系统后,自动为root用户,所以一下命令不需要 sudo .

首先,更新:apt-get update

然后,输入:ifconfig

若报错,则安装:apt install net-tools

4. 在Docker中的ubuntu中安装 Python3 和 Pip

apt-get install python3
apt-get install python3-pip

5. windows 的 Docker 中安装的 Ubuntu 无法修改文件权限

Docker 中安装的 Ubuntu 读取 ssh 的密钥时,被警告说:755 file is too open ,然后失败。

即使在Windows 中将 private key 的权限已经修改为仅拥有者可读写,即 600,依然失败。

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0755 for '/gpu/login.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/gpu/login.pem": bad permissions

问题核心似乎是:Windows的文件系统与Linux的文件系统冲突,在Windows中的Docker上搭建的Linux环境,无法修改并读取Windows的文件权限。

可能的解决方案:Change file permissions in mounted folder inside docker container on Windows Host - Stack Overflow

状态:解决(2021-10-22),执行 df -h 后,可看到 Docker中Ubuntu的空间状态如下:

其中 /gpu 是挂载的 Windows 上的文件夹, overlay 是纯 Linux 的文件夹。把要修改权限的文件复制到 overlay 上,即可按照Linux的方式修改、读取权限。

具体方法是:可以将文件复制到 /home 中,然后执行操作即可。

6. docker 容器内以非root登陆的方法

https://segmentfault.com/a/1190000040466843

7. sh: 1: rsync: not found

首先,查看本机中是否有 rsync:  which rsync

有的话,应显示: /usr/bin/rsync

如果没有,则安装:

apt update; apt install -y rsync

如果安装后,还显示 sh: 1: rsync: not found ,那就要检测远程的服务器有没有安装 rsync, 因为有可能是因为:线上的新服务器没有安装rsync导致。

8. rsync: Failed to exec ssh: No such file or directory (2)

rsync: Failed to exec ssh: No such file or directory (2)
rsync error: error in IPC code (code 14) at pipe.c(85) [sender=3.1.3]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in IPC code (code 14) at io.c(235) [sender=3.1.3]

原因:缺失SSH客户端,安装即可:

apt-get install openssh-server

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值