我是 docker 和 linux 的新手。
我正在使用 Windows 10 并获得了一个 github 示例来使用 Centos 和 nginx 创建一个容器。
我需要使用 root 用户来更改 nginx.config。
在 Kitematic 中,我单击 Exec 以在容器中获取一个 bash shell,然后我尝试了 sudo su – 作为打击:
sh-4.2$ sudo su –
sh: sudo: command not found
因此,我尝试通过以下命令安装 sudo:
sh-4.2$ yum install sudo -y
Loaded plugins: fastestmirror, ovl
ovl: Error while doing RPMdb copy-up:
[Errno 13] Permission denied: '/var/lib/rpm/Installtid'
You need to be root to perform this command.
然后我跑了 su - ,但我不知道密码!如何设置密码?
sh-4.2$ su -
Password:
然后,从我的 Windows 上的 powershell 我也尝试了:
PS C:\Containers\nginx-container> docker exec -u 0 -it 9e8f5e7d5013 bash
但它显示脚本正在运行并且没有发生任何事情,我在一小时后通过 Ctrl+C 取消了它。
一些附加信息:
这是我创建容器的方式:
PS C:\Containers\nginx-container> s2i build https://github.com/sclorg/nginx-container.git --context->dir=examples/1.12/test-app/ centos/nginx-112-centos7 nginx-sample-app
从容器中的 bash shell。我可以得到如下的操作系统信息:
sh-4.2$ cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
如果您能帮助我解决这些问题,我将不胜感激。
谢谢!