0

I'm running lamp container. So from my app running on apache server I need to upload a file. I keep getting an error: The upload destination folder does not appear to be writable. So, I need to give permission to the folder located in /Documents/Kitematic/lamp/app/appv2/uploads to be written... How can I do that? I already tried "mkdir 077 directory" but is not working. Following you can see all my permissions:

 # ls -al
 total 96
 drwxr-xr-x   1 root     root  4096 Sep 16 10:45 .
 drwxr-xr-x   1 root     root  4096 Sep 16 10:45 ..
 drwxr-xr-x   2 root     root  4096 Sep 16 10:45 0777
 drwxr-xr-x   9 www-data staff  306 Sep 16 09:06 app
 drwxr-xr-x   1 root     root  4096 Aug 16  2018 bd_build
 drwxr-xr-x   1 root     root  4096 Jun 12 19:16 bin
 drwxr-xr-x   2 root     root  4096 Apr 24  2018 boot
 -rwxr-xr-x   1 root     root  2049 Jun 12 19:13 create_mysql_users.sh
 drwxr-xr-x   5 root     root   360 Sep 16 13:16 dev
 -rwxr-xr-x   1 root     root     0 Sep 16 09:11 .dockerenv
 drwxr-xr-x   1 root     root  4096 Sep 16 09:11 etc
 drwxr-xr-x   2 root     root  4096 Apr 24  2018 home
 drwxr-xr-x   1 root     root  4096 Jul 24  2018 lib
 drwxr-xr-x   2 root     root  4096 Jul 24  2018 lib64
 drwxr-xr-x   2 root     root  4096 Jul 24  2018 media
 drwxr-xr-x   2 root     root  4096 Jul 24  2018 mnt
 drwxr-xr-x   2 root     root  4096 Jul 24  2018 opt
 dr-xr-xr-x 194 root     root     0 Sep 16 13:16 proc
 drwx------   1 root     root  4096 Jun 12 19:18 root
 drwxr-xr-x   1 root     root  4096 Sep 16 13:16 run
 -rwxr-xr-x   1 root     root  2160 Jun 12 19:13 run.sh
 drwxr-xr-x   1 root     root  4096 Jun 12 19:16 sbin
 drwxr-xr-x   2 root     root  4096 Jul 24  2018 srv
 -rwxr-xr-x   1 root     root    67 Jun 12 19:13 start-apache2.sh
 -rwxr-xr-x   1 root     root    29 Jun 12 19:13 start-mysqld.sh
 dr-xr-xr-x  13 root     root     0 Sep 16 13:16 sys
 drwxrwxrwt   1 root     root  4096 Sep 16 13:18 tmp
 drwxr-xr-x   1 root     root  4096 Jul 24  2018 usr
 drwxr-xr-x   1 root     root  4096 Jun 12 19:17 var
mandiatutti
  • 57
  • 1
  • 10

1 Answers1

0

Use ls -al inside the container to see the current permissions. Use id to see the current uid.

With docker exec you can pass a flag to change the current user. And to change permissions, you can use chmod to change the permissions themselves, chown to change the user ownership.

e.g

docker exec -u root container_1 chmod 777 .

This command will allow any user to read or write to the current folder inside the container by running as the root.

Majid Rehman
  • 151
  • 6
  • $ docker exec lamp id uid=0(root) gid=0(root) groups=0(root). Apparently everyone is root... – mandiatutti Sep 16 '19 at 13:58
  • The uid you are running commands as (this defaults to root, but can be overridden in your image with a USER command in the Dockerfile, or on the docker run cli, or within your docker-compose.yml file). The location where your command runs since you are using a relative path. This will default to /, but again can be overridden by changing the working directory in various ways, most often with the WORKDIR within the Dockerfile. The directory and file permissions at that location. – Majid Rehman Sep 17 '19 at 07:12
  • Docker runs commands as a linux user which is bound to linux filesystem permissions. – Majid Rehman Sep 17 '19 at 07:13
  • Can you please tell me how to add my path to that list with privilidges? Honestly I've been told to follow a tutorial on a pdf to install this container and it is my first experience with docker... – mandiatutti Sep 17 '19 at 07:49
  • Look similar question which is already answered https://stackoverflow.com/questions/45972608/how-to-give-folder-permissions-inside-a-docker-container-folder – Majid Rehman Sep 17 '19 at 07:54
  • If you still have problem , do let me know i will help you – Majid Rehman Sep 17 '19 at 07:54
  • Could not find before asking any work in sololution for me.. Also I didn't know what I need – mandiatutti Sep 17 '19 at 07:55
  • This path is in container ? /Documents/Kitematic/lamp/app/appv2/uploads – Majid Rehman Sep 17 '19 at 08:55
  • The container is called lamp and is located In /Documents/Kitematic/lamp. The one you wrote Is the folder I'd like to upload in... Unfortunately I'm outside this morning, as I get back I try solve this... – mandiatutti Sep 17 '19 at 08:59
  • bash-3.2$ FROM python:2.7 FROM: can't read /var/mail/python:2.7 I'm not starting very well xD – mandiatutti Sep 17 '19 at 09:26