"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 Oracle, Docker, Sudo, Root
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 [文件夾] 進行修改,然後再進行部署操作,不得不說國內網站真的是很少人遇到這樣的問題,或者說是將自己的答案分享到某個地方,希望更多的人能夠寫一下博客來共享自己的經驗。
打賞二維碼,多謝支持