New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission denied on mkdir /bitnami/mariadb with boot2docker #110

Closed
insuusvenerati opened this Issue Jan 29, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@insuusvenerati
Copy link

insuusvenerati commented Jan 29, 2018

Description

When spinning up a bare docker-machine -d virtualbox and running docker-compose up after changing environment the mariadb container exits with error mariadb_1 | Error executing 'postInstallation': EACCES: permission denied, mkdir '/bitnami/mariadb'

Steps to reproduce the issue:

  1. docker-machine create -d virtualbox
  2. docker-machine env
  3. docker-compose up

Describe the results you received:

https://h.stiforr.com/awawusiqow.coffeescript

Describe the results you expected:

mariadb container start.

Additional information you deem important (e.g. issue happens only occasionally):

Version

- Output of `docker version`:
Client:
 Version:	18.01.0-ce
 API version:	1.35
 Go version:	go1.9.2
 Git commit:	03596f51b1
 Built:	Sun Jan 14 23:10:39 2018
 OS/Arch:	linux/amd64
 Experimental:	false
 Orchestrator:	swarm

Server:
 Engine:
  Version:	18.01.0-ce
  API version:	1.35 (minimum version 1.12)
  Go version:	go1.9.2
  Git commit:	03596f5
  Built:	Wed Jan 10 20:13:12 2018
  OS/Arch:	linux/amd64
  Experimental:	false
  • Output of docker info:
Containers: 2
 Running: 0
 Paused: 0
 Stopped: 2
Images: 3
Server Version: 18.01.0-ce
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 29
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 89623f28b87a6004d4b785663257362d1658a729
runc version: b2567b37d7b75eb4cf325b77297b140ea686ce8f
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.4.111-boot2docker
Operating System: Boot2Docker 18.01.0-ce (TCL 8.2.1); HEAD : 0bb7bbd - Thu Jan 11 16:32:39 UTC 2018
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 995.9MiB
Name: wordpress
ID: ZRIK:TC42:IOQ7:K3AP:GH37:OFQD:KGRF:2LL6:5MTL:5ORY:X4XO:HZX6
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 19
 Goroutines: 34
 System Time: 2018-01-29T22:26:17.682614196Z
 EventsListeners: 0
Username: stiforr
Registry: https://index.docker.io/v1/
Labels:
 provider=virtualbox
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

  • Output of docker-compose version (if applicable):
docker-compose version 1.18.0, build unknown
docker-py version: 2.7.0
CPython version: 3.6.4
OpenSSL version: OpenSSL 1.1.0g  2 Nov 2017

Additional environment details (AWS, VirtualBox, Docker for MAC, physical, etc.):

λ docker-machine version
docker-machine version 0.13.0, build HEAD
λ uname -a
Linux arch 4.14.13-1-ck-piledriver #1 SMP PREEMPT Wed Jan 10 16:00:16 EST 2018 x86_64 GNU/Linux
λ git status                                                     
On branch master
Your branch is up to date with 'origin/master'.
@juan131

This comment has been minimized.

Copy link
Contributor

juan131 commented Jan 30, 2018

Hi @insuusvenerati

It seems that you're attaching a volume to the MariaDB container with no writing permissions for the user mysql. You can try to change the permissions of the local directory attached as a volume to the MariaDB container to avoid that permission error:

$ chown -R 1001:1001 /path/to/your/mariadb_data
@insuusvenerati

This comment has been minimized.

Copy link
Author

insuusvenerati commented Jan 30, 2018

The mkdir error is coming from inside the container. I'm using the unmodified bitnami wordpress docker compose which uses named volumes so there isn't any volumes on the host. Might be worth nothing this issue doesn't occur on Ubuntu 16.04

@sameersbn

This comment has been minimized.

Copy link
Contributor

sameersbn commented Jan 31, 2018

@insuusvenerati I followed your instructions and did not face any issues.

For reference:

$ docker version
Client:
 Version:	18.02.0-ce-rc1
 API version:	1.35
 Go version:	go1.9.2
 Git commit:	5e1d90a
 Built:	Thu Jan 25 00:33:50 2018
 OS/Arch:	darwin/amd64
 Experimental:	true
 Orchestrator:	kubernetes
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

However the issue you are noticing is due to the non-root changes done to the mariadb image. You should try either of the following docker-compose files to resolve this issue

Option 1

Launch the mariadb container as the root user. This means the container will have all the required permissions to give ownership of the mysql data directories to the mysql user.

version: '2'
services:
  mariadb:
    user: root
    image: 'bitnami/mariadb:latest'
    volumes:
      - 'mariadb_data:/bitnami'
    environment:
      - MARIADB_USER=bn_wordpress
      - MARIADB_DATABASE=bitnami_wordpress
      - ALLOW_EMPTY_PASSWORD=yes
  wordpress:
    image: 'bitnami/wordpress:latest'
    labels:
      kompose.service.type: nodeport
    ports:
      - '80:80'
      - '443:443'
    volumes:
      - 'wordpress_data:/bitnami'
    depends_on:
      - mariadb
    environment:
      - MARIADB_HOST=mariadb
      - MARIADB_PORT_NUMBER=3306
      - WORDPRESS_DATABASE_USER=bn_wordpress
      - WORDPRESS_DATABASE_NAME=bitnami_wordpress
      - ALLOW_EMPTY_PASSWORD=yes
volumes:
  mariadb_data:
    driver: local
  wordpress_data:
    driver: local

Option 2

Create a container to fix the permissions of the mounted volume

version: '2'
services:
  fix-mariadb-volume-ownership:
    image: 'bitnami/mariadb:latest'
    user: root
    command: chown -R 1001:1001 /bitnami
    volumes:
      - 'mariadb_data:/bitnami'
  mariadb:
    image: 'bitnami/mariadb:latest'
    volumes:
      - 'mariadb_data:/bitnami'
    environment:
      - MARIADB_USER=bn_wordpress
      - MARIADB_DATABASE=bitnami_wordpress
      - ALLOW_EMPTY_PASSWORD=yes
    depends_on:
      - fix-mariadb-volume-ownership
  wordpress:
    image: 'bitnami/wordpress:latest'
    labels:
      kompose.service.type: nodeport
    ports:
      - '80:80'
      - '443:443'
    volumes:
      - 'wordpress_data:/bitnami'
    depends_on:
      - mariadb
    environment:
      - MARIADB_HOST=mariadb
      - MARIADB_PORT_NUMBER=3306
      - WORDPRESS_DATABASE_USER=bn_wordpress
      - WORDPRESS_DATABASE_NAME=bitnami_wordpress
      - ALLOW_EMPTY_PASSWORD=yes
volumes:
  mariadb_data:
    driver: local
  wordpress_data:
    driver: local

@juan131 juan131 closed this Oct 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment