How to solve permission denied inside docker container? - docker

I am using the docker file for project API Sprout.
I want to launch the executable inside the docker container on a local file called open_api.json. Following the README, I run:
docker run -p 8000:8000 -v $(pwd)open_api.json:/api.json danielgtaylor/apisprout /api.json
But it fails with
[..datetime...] open /tmp/api.json: permission denied
How should I give the right permission / user to the file or container?

you need to give the api.json file the correct permissions.
for test give use:
chmod 777 api.json
. if it works change the permissions to something more restricted
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Step_by_Step_Guide/s1-navigating-ownership.html

Related

Docker Vs Code Container files not showing

I have created docker container with following command
docker run -p 8081:80 -v $(pwd)/lemp1:/var/www/html --name lemp1 -d adhocore/lemp:8.1
Now I work on lemp1 folder. I am trying to create files and folder on lemp1 folder from file manager in windows (Using WSL2) and getting permission denied error.
PS Microsoft.PowerShell.Core\FileSystem::\\wsl.localhost\Ubuntu-22.04\home\myuser\development\lemp1> mkdir sdsdf
New-Item: Access to the path '\\wsl.localhost\Ubuntu-22.04\home\myuser\development\lemp1\sdsdf' is denied.
PS Microsoft.PowerShell.Core\FileSystem::\\wsl.localhost\Ubuntu-22.04\home\myuser\development\lemp1>
And If I remote open docker container with vs code, I dont see any files there. I only see .composer and .vscode server folders. I dont know how to access my lemp1 folder in vs code the right way.
The wow dir I created with vscode remote container mode. But I want my lemp dir here. Not the .composrer and .vscode dirs.
I cant access the lemp1 folder in Windows file explorer because of permission denied error.
the folder I created with docker exec command bin/sh
I want to access container in Windows file explorer and Vs code lemp1 folder as docker container.

trouble installing gitlab docker image. permission denied error

I am trying to build gitlab using docker and keep getting this error message.
cp: cannot create regular file '/etc/gitlab/gitlab.rb': Permission denied
it looks like GITLAB_OMNIBUS_CONFIG is the issue.
I don't know how to resolve the issue. Please help!
It depends when you are getting the error message: on docker build or docker run.
In the latter case (runtime), you would need to mount your user folder (where you have the right to write) to GitLab container, as in here:
--volume /Users/username/gitlab/config:/etc/gitlab \
--volume /Users/username/gitlab/logs:/var/log/gitlab \
--volume /Users/username/gitlab/data:/var/opt/gitlab \
Official documentation:
Set up the volumes location
Before setting everything else, configure a new environment variable $GITLAB_HOME pointing to the directory where the configuration, logs, and data files will reside.
Ensure that the directory exists and appropriate permission have been granted.
For macOS users, use the user’s $HOME/gitlab directory:
export GITLAB_HOME=$HOME/gitlab

Permission denied for docker-compose Superset

I am trying to get the Superset running on ubuntu server. I have referenced the steps from Superset page as below:
git clone https://github.com/apache/incubator-superset/
cd incubator-superset/contrib/docker
# prefix with SUPERSET_LOAD_EXAMPLES=yes to load examples:
docker-compose run --rm superset ./docker-init.sh
# you can run this command everytime you need to start superset now:
docker-compose up
I have fixed the initial issues around right version of docker-compose and postgress address bind issue on port 5432. So after fixing those my docker compose run command
docker-compose run --rm superset ./docker-init.sh
works fine and it asks me to set up a user name and password.
Finally to get the container running I run the final command
docker-compose up.
On my mac, it would run redis, postrgre container and then give me a localhost:8088 for me to get access to Superset UI with login info.
However on Ubuntu, when I run that, I first get this:
So looks it is running redis and postgres containers fine.
But then it is giving me Permission denied errors to create some mkdir directory.
Pls note I am running it as root user.
Also, my docker compose version is fine with 1.23.2 and my docker along with docker-compose is installed under
/usr/bin/docker and not /usr/local/bin/docker.
But I think that shouldn't be an issue.
Any help where it is going wrong and how can I fix it?
Thanks
Edit:
Ok I looked at the same issue mentioned on Github. And used a suggestion of using it only for Production and not development in docker-compose.yml file.
It seems to not throw the same error now when I do
docker-compose up.
However when I open localhost:8088 it does not connect to the UI.
try this:
mkdir ../../assets
chmod -R 777 ../../superset/assets/
as set in docker-compose.yml#L64, it is using ../../superset as volume when in develop. However the container does not have any permission in the host so the solution is to make a directory by yourself and grant the necessary permissions on to it.

Always ask password on local file when modified file when ran docker container

I'm newbie in docker. And i tried to create a Dockerfile to run a website was written byrails, postgresql on apache+passenger.
But when i run Dockerfile, it run successfully, but it had a problem with permission denied. I found problem that folder web must belongs to apache user. Then i tried to change apache user to source web (on container). And it run ok.
But every time i modified a file on local. It always ask password when i saved this file.
And i checked permission source on local. It changed all role to weird role.
How can i solved this problem ?
This is my Dockerfile.
And i used two commands to run.
docker build -t wics .
docker run -v /home/khanhpn/Project/wics:/home/abc -p 80:80 -it wics /bin/bash
After a mount of time, i found a solution to solve this problem.
I just add this line in Dockerfile, the problem was solved.
RUN usermod -u 1000 apache

Volume on host - permission denied for Postgres (Mac OS)

I am starting Postgresql image with following volume
/Users/me/Desktop/volumes/postgresql/data:/var/lib/postgresql/data
According to docker docs it should work as docker should have access to /Users directory on Mac OS. After creating & runing container I can see
that empty directory /Users/me/Desktop/volumes/postgresql/data is created however Postgres does not start and show these lines in log:
could not create directory "/var/lib/postgresql/data/global": Permission denied
What I am doing wrong?
Your directory belongs to a different User then the user, that the User that executes the container.
Could you change your directory like that for a start.
chmod 777 /Users/me/Desktop/volumes/postgresql/data
If you can start your container with this setting, then this missing permissions are the root cause.
You could then try to start your container with
run -u uid ...
and specify the userid of your user on macos.
You have to create the user in boot2docker too, i.e.
boot2docker ssh
sudo sh
adduser <anyuserid> -u <your uid>
I had the same problem.
What I done was the workaround by creating the folder inside the Virtual Box.
Set your docker-compose.yml postgresql folder:
/Users/me/Desktop/volumes/postgresql/data
to
/root/data
Enter at the Docker at Virtual Box and create the data folder

Resources