Volume odoo. Permission issue - docker

Ubuntu 18.04. I am using odoo docker files
docker-compose:
version: '3.7'
services:
web:
build: ./build
# image: odoo:13.0
# user: root
depends_on:
- mydb
ports:
- "18275:8069"
environment:
- HOST=mydb
- USER= us
- PASSWORD=pw
restart: always
volumes:
- ./odoo:/usr/lib/python3/dist-packages/odoo
- ./config:/etc/odoo
- ./extra-addons:/mnt/extra-addons
mydb:
image: postgres:12.1
environment:
- POSTGRES_DB=postgres
- POSTGRES_PASSWORD=pw
- POSTGRES_USER=us
restart: always
In ./build directory I have docker files from odoo github repository.
I have problems with volumes: ./odoo:/usr/lib/python3/dist-packages/odoo
My odoo container is restarting with logs:
web_1 | Traceback (most recent call last):
web_1 | File "/usr/bin/odoo", line 8, in <module>
web_1 | odoo.cli.main()
web_1 | AttributeError: module 'odoo' has no attribute 'cli'
I think it's permission issue. I added some permission, I changed user and group owner and nothing...
What should I do to create this volume?
Without this one volume everything works great

Sorry my answer is so late - maybe we can help someone else who has this error.
Consider how simple Odoo-bin is:
#!/usr/bin/env python3
# set server timezone in UTC before time module imported
__import__('os').environ['TZ'] = 'UTC'
import odoo
if __name__ == "__main__":
This error: "odoo has no attribute 'cli'" can happen if the odoo program files are not where Odoo-bin expects them to be. The fifth line in Odoo-bin is 'import odoo', and if it isn't there, you will get this error.
And as you have guessed, if your odoo user doesn't have permissions to READ the odoo files, Odoo-bin will also throw this error when it cannot import from a folder it cannot even see.

Related

How do I give access to container to have full access for a bind volume

I have a problem deploying some docker images when I use bind volumes and when I check the logs I see errors like access denied when the docker application try to create a folder. For example the following docker compose create two containers, one for the postgres database and one for the postgres admin panel.
version: '3.7'
services:
PostgresDB:
image: postgres
environment:
- POSTGRES_DB=MyDatabase
- POSTGRES_USER=MyUser
- POSTGRES_PASSWORD=MyPassword
volumes:
- ./data:/var/lib/postgresql/data
ports:
- '5432:5432'
PostgresDBAdmin:
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: example#example.com
PGADMIN_DEFAULT_PASSWORD: MyPasword
PGADMIN_CONFIG_SERVER_MODE: 'False'
volumes:
- pgadmin:/var/lib/pgadmin
ports:
- "5050:80"
volumes:
pgadmin:
For the database I use bind volume but for the panel I use normal volume. The application works fine. If I change the panel container to use bind volumes my docker compose file looks like this
version: '3.7'
services:
PostgresDB:
image: postgres
environment:
- POSTGRES_DB=MyDatabase
- POSTGRES_USER=MyUser
- POSTGRES_PASSWORD=MyPassword
volumes:
- ./data:/var/lib/postgresql/data
ports:
- '5432:5432'
PostgresDBAdmin:
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: example#example.com
PGADMIN_DEFAULT_PASSWORD: MyPasword
PGADMIN_CONFIG_SERVER_MODE: 'False'
volumes:
- ./pgadmin:/var/lib/pgadmin
ports:
- "5050:80"
This will have as a result the panel container to fail because of directory permission problem. The generated error log looks like this
PostgresDBAdmin_1 | ERROR : Failed to create the directory /var/lib/pgadmin/sessions:
PostgresDBAdmin_1 | [Errno 13] Permission denied: '/var/lib/pgadmin/sessions'
PostgresDBAdmin_1 | HINT : Create the directory /var/lib/pgadmin/sessions, ensure it is writeable by
PostgresDBAdmin_1 | 'pgadmin', and try again, or, create a config_local.py file
PostgresDBAdmin_1 | and override the SESSION_DB_PATH setting per
PostgresDBAdmin_1 | https://www.pgadmin.org/docs/pgadmin4/6.18/config_py.html
PostgresDBAdmin_1 | Traceback (most recent call last):
PostgresDBAdmin_1 | File "/pgadmin4/pgadmin/setup/data_directory.py", line 82, in create_app_data_directory
PostgresDBAdmin_1 | _create_directory_if_not_exists(config.SESSION_DB_PATH)
PostgresDBAdmin_1 | File "/pgadmin4/pgadmin/setup/data_directory.py", line 20, in _create_directory_if_not_exists
PostgresDBAdmin_1 | os.mkdir(_path)
PostgresDBAdmin_1 | PermissionError: [Errno 13] Permission denied: '/var/lib/pgadmin/sessions'
This kind of problem is rare and I try to find a way to give access to the container to create the directory but I did not find a way to do it. The reason that I want to be able to use bind volumes is because in cases like NopCommerce it makes easier for me to have access to the files in order to create a theme.
Can someone help me to solve this problem?
The pgadmin container process runs under a user with UID 5050.
That user needs to have access to the ./pgadmin directory on the host.
One way to do that is to create a user on the host with that UID and make it a member of a group that has access to the ./pgadmin directory.
If, for instance, ./pgadmin is owned by you and your group that are both called 'pitaridis', then you can create a user called 'pgadmin' like this
sudo adduser --system --no-create-home --uid 5050 --ingroup pitaridis --shell /usr/sbin/nologin pgadmin
Then the container process can access ./pgadmin and create the files that it needs.
Another way that may be easier but is less secure, is to run the container as root, like this:
PostgresDBAdmin:
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: example#example.com
PGADMIN_DEFAULT_PASSWORD: MyPasword
PGADMIN_CONFIG_SERVER_MODE: 'False'
volumes:
- ./pgadmin:/var/lib/pgadmin
ports:
- "5050:80"
user: root
You have to specify user:root inside the PostgreAdmin Service. And the result of the docker compose file look like this :
PostgresDBAdmin:
image: dpage/pgadmin4
user: root
environment:
PGADMIN_DEFAULT_EMAIL: example#example.com
PGADMIN_DEFAULT_PASSWORD: MyPasword
PGADMIN_CONFIG_SERVER_MODE: 'False'
volumes:
- ./pgadmin:/var/lib/pgadmin
ports:
- "5050:80"

Permission Denied when start the Redis in docker from Windows OS

Can anyone please explain what is the issue here and how to resolve that?
While I try to start the redis in docker desktop from windows OS, it always returning the error ""redis-redis-1 | 1:M 21 Jun 2022 14:40:59.452 # Can't open the append-only file: Permission denied
Here is my dockercompose file,
version: '2'
services:
redis:
image: 'docker.io/bitnami/redis:6.0-debian-10'
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
- REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL
ports:
- '6379:6379'
volumes:
- '/home/vagrant/var/Redis:/bitnami/redis/data'
The second image is the files from the redis-data folder.
In your docker-compose file, change the line:
'/home/vagrant/var/Redis:/bitnami/redis/data'
to
./redis_data/:/bitnami/redis/data/
Since redis_data is the folder you are trying to mount to the container.

Docker parsing error whilst setting up MediaWiki on RaspberryPi3

Just for some background, I am setting up mediawiki on a raspberry pi3 for a personal learning project.
I have followed the guide from https://peppe8o.com/personal-mediawiki-with-raspberry-pi-and-docker/ and have been able to follow all but the very last step of running 'docker-compose up -d' and get the error below (I have also pasted the contents of my docker-compose.yml)
I would greatly appreciate if anyone could spot the issue here as I have tried a number of things
(removing and adding spaces in lines 6 & 17 etc....)
pi#raspberrypi:~/mediawiki $ docker-compose up -d
ERROR: yaml.parser.ParserError: while parsing a block mapping
in "./docker-compose.yml", line 6, column 3
expected <block end>, but found '-'
in "./docker-compose.yml", line 17, column 3
Contents of docker-compose.yml:
# My MediaWiki
# from peppe8o.com
version: '3'
services:
mediawiki:
image: mediawiki
restart: unless-stopped
ports:
- 8080:80
links:
- database
volumes:
- mediawiki-www:/var/www/html
#After initial setup, download LocalSettings.php to the same directory as
#this yaml and uncomment the following line and use compose to restart
#the mediawiki service
- ./LocalSettings.php:/var/www/html/LocalSettings.php
database:
build: .
restart: unless-stopped
volumes:
- mediawiki-db:/var/lib/mysql
volumes:
mediawiki-www:
mediawiki-db:
Kind regards
Layerz

When Does docker-compose call the Dockerfile?

I'm a little bit confused, I have a docker-compose file where I am trying to install apache and mariadb...
web:
image: php:5.6-apache
volumes:
- ./:/var/www/html/
environment:
- ALLOW_OVERRIDE=true
ports:
- "80:80"
links:
- db
db:
image: mariadb
restart: always
volumes:
- ./docker/db:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: admin
MYSQL_PASSWORD: test
MYSQL_DATABASE: database
ports:
- "8889:3306"
Everything works fine until I try and do some URL rewriting in Apache and I get this...
web_1 | [Thu Apr 12 16:55:31.646473 2018] [core:alert] [pid 18] [client 172.17.0.1:34330] /var/www/html/applications/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
So I follow some online instructions to add a Dockerfile with...
FROM php:5.6-apache
MAINTAINER Raphael Mäder <ra#mader.com>
RUN a2enmod rewrite
ADD . /var/www/html
But it doesn't fix the problem. In fact even when I add an error into the file like this...
FROM php:5.6-apache
bleurrrrgggghhh
MAINTAINER Raphael Mäder <ra#mader.com>
RUN a2enmod rewrite
ADD . /var/www/html
And then call docker-compose everything boots up fine. So I know that the docker file can't be getting called. Even when I remove the image with docker-compose rm and restart it still nothing.
Am I getting confused about how I can run get the Dockerfile command working?
Once the image is built, it won't be built again, unless you explicitly want it to be rebuilt. With docker-compose, you pass the --build to force the image to be rebuilt.
docker-compose up --build web

Docker compose error while creating mount source path

I have created a docker-compose.yml using cloudestuary. After downloading it and putting it in my Laravel project folder and running docker-compose up -d the download takes place and then I get this message:
ERROR: for worker-1 Cannot start service worker-1: error while creating mount source path '/var/www/html/lensin/html': mkdir /var/www: read-only file system
ERROR: for nginx Cannot start service nginx: error while creating mount source path '/var/www/html/lensin/html': mkdir /var/www: read-only file system
ERROR: for app Cannot start service app: error while creating mount source path '/var/www/html/lensin/html': mkdir /var/www: read-only file system
ERROR: for workspace Cannot start service workspace: error while creating mount source path '/var/www/html/lensin/html': mkdir /var/www: read-only file system
ERROR: Encountered errors while bringing up the project.
I`m on Ubuntu 17, and have tried even to set 777 to all folders, and running it with sudo, but the result is the same. I have also tried to move the file and to edit the volumes in yml.
Here is my docker compose file:
version: '2'
services:
nginx:
image: 'cloudestuary/nginx:mainline-fpm'
restart: always
environment:
CLIENT_MAX_BODY_SIZE: 100m
DOCUMENT_ROOT: /var/www/html/public
INDEX_FILE: index.php
PHP_FPM: app
networks:
- app
volumes:
- './html:/var/www/html'
ports:
- '80:80'
app:
image: 'cloudestuary/php-fpm:7.1'
restart: always
environment:
MAX_UPLOAD_FILE_SIZE: 100m
APP_URL: 'http://lensin.localhost'
APP_KEY: 'base64:2X9U1HiBdmfbwvZ4UkwUP/25svg7439HXKWL1F8Xn1c='
DB_CONNECTION: mysql
DB_HOST: mysql
DB_PORT: '3306'
DB_DATABASE: cloudestuary
DB_USER: cloudestuary
DB_PASSWORD: secret
networks:
- app
volumes:
- './html:/var/www/html'
workspace:
image: 'cloudestuary/php-workspace:7.1'
restart: always
ports:
- '2222:22'
environment:
MAX_UPLOAD_FILE_SIZE: 100m
APP_URL: 'http://lensin.localhost'
APP_KEY: 'base64:2X9U1HiBdmfbwvZ4UkwUP/25svg7439HXKWL1F8Xn1c='
DB_CONNECTION: mysql
DB_HOST: mysql
DB_PORT: '3306'
DB_DATABASE: cloudestuary
DB_USER: cloudestuary
DB_PASSWORD: secret
SSH_PASSWORD: xsKEVWXPrdAeg
networks:
- app
volumes:
- './html:/var/www/html'
worker-1:
image: 'cloudestuary/php-cli:7.1'
restart: always
networks:
- app
environment: { }
volumes:
- './html:/var/www/html'
command: 'php artisan queue:work'
mysql:
image: 'mysql:5.7'
restart: always
networks:
- app
environment:
MYSQL_ROOT_PASSWORD: toor
MYSQL_PASSWORD: secret
MYSQL_USER: cloudestuary
MYSQL_DATABASE: cloudestuary
volumes:
- 'mysql-data:/var/lib/mysql'
volumes:
mysql-data: { }
networks:
app: { }
It's likely a pathing issue with Docker when installed with snap, you're better off installing it with the official documentation from Docker.
Remove docker from snap
snap remove docker
Remove the docker directory, and old version (It's okay if these don't exist already)
rm -R /var/lib/docker
sudo apt-get remove docker docker-engine docker.io
Install the official docker package: https://docs.docker.com/install/linux/docker-ce/ubuntu/
Update: Since posting this answer, I've learnt that tools installed using snap are installed in a sandbox with limited permissions outside of that sandbox. This is likely the cause as docker won't have access to the external filesystem from its isolated sandbox environment.
Restart your docker service. Then the problem will solve.
sudo systemctl restart docker
What led me here was the Kubernetes V1VolumeMount. When deploying my application I was getting the same error format:
ERROR: for <pod_name> Cannot start <service_name>: error while creating mount source path '<source_path>': mkdir <dir_path>: read-only file system
At the start I was thinking permissions error as well, hence the message is a bit misleading. I turned out that I was trying to mount something that didn't exist in the source image. Hence, my uneducated suggestion would be, verify that what you are trying to mount does exist, if it doesn't you probably don't need that mount path.
P.S. I saw that there wasn't an accepted answer, so I am hoping that my contribution is not causing unnecessary cluttering.
Got this error but the issue was that the source path was a symlink. For some reason docker does not seem to like it, even after restarting the service.
Had to use a real path and then it worked just fine with Docker version 20.10.8 installed with snap.
For Docker on Windows 10, sometimes you have just to wait a while (1-5 min) before executing docker-compose up again.
Hope this will help someone else.

Resources