"chdir to cwd (\"/u01/oracle\") set in config.json failed: permission denied": unknown

出现这个问题我在国内的网址找不到任何答案,但是通过google找到了正确的答案

请自行穿越到国外查看此网址

https://rmoff.net/2018/11/30/logging-in-as-root-on-oracle-database-docker-image/

具体内容如下所示,我已经复制过来了

Logging in as root on Oracle Database Docker image

Published Nov 30, 2018 in OracleDockerSudoRoot

tl;dr:

docker exec --interactive \
            --tty \
            --user root \
            --workdir / \
            oracle-container-name bash

Using Oracle’s Docker database image I wanted to install some additional apps, without modifying the Dockerfile.

Connect to the container:

$ docker exec --interactive --tty docker-compose_oracle_1_479e7fa05ab5 bash

No sudo:

[oracle@a37d6e99353b ~]$ sudo whoami
bash: sudo: command not found

Googled, found the the --user flag for Docker, tried that:

$ docker exec --interactive --tty --user root docker-compose_oracle_1_479e7fa05ab5 bash
OCI runtime exec failed: exec failed: container_linux.go:348: starting container process caused "chdir to cwd (\"/home/oracle\") set in config.json failed: permission denied": unknown

Evidently, the Docker image tries to change directory to the Oracle home folder which Docker’s not happy doing as another user (even though it’s root?).

Googled some more, found the --workdir flag to override the WORKDIR setting of the Dockerfile from which the image is built:

$ docker exec --interactive --tty --user root --workdir / docker-compose_oracle_1_479e7fa05ab5 bash
bash-4.2# whoami
root

答案就在最后一行

docker exec --interactive --tty --user root --workdir / docker-compose_oracle_1_479e7fa05ab5 bash

 这样就可以进入到root权限了,因为部署一些东西需要将文件上传到weblogic容器中,但是docker cp的操作不能改变root权限,通过exec 进入到容器会发现是oracle的用户,你无法su root也没有密码,所以只能通过上面的方式进行,然后将文件的权限通过chown -R oracle:oracle [文件夹]  进行修改,然后再进行部署操作,不得不说国内网站真的是很少人遇到这样的问题,或者说是将自己的答案分享到某个地方,希望更多的人能够写一下博客来共享自己的经验。

打赏二维码,多谢支持

 

 

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐