Will
Will

Reputation: 482

Unable to start mysql with docker on Ubuntu 16.04

Am Unable to start mysql with docker on Ubuntu. Get the following error:

db_1_cc1214d5085c | ERROR: mysqld failed while attempting to check config db_1_cc1214d5085c | command was: "mysqld --verbose --help" db_1_cc1214d5085c | db_1_cc1214d5085c | mysqld: error while loading shared libraries: libpthread.so.0: cannot stat shared object: Permission denied

Content of docker compose file:

version: '2.4'

services:

  db:
    image: mysql:5.7
    ports:
      - "32000:3306"
    environment:
      MYSQL_ROOT_PASSWORD: root
#   restart: always
    volumes:
     - ./data/db:/var/lib/mysql

Docker details:

Client:
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:48:57 2018
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community

Engine:
  Version:          18.09.0
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       4d60db4
  Built:            Wed Nov  7 00:16:44 2018
  OS/Arch:          linux/amd64
  Experimental:     false

Also worth noting is that there is a non dockerized versionof MySQL installed and running on this server. Any help will be appreciated.

Upvotes: 2

Views: 6548

Answers (1)

Mohamed Hamza
Mohamed Hamza

Reputation: 216

To start mysql service you'll need to have something like this in your docker-compose file

version: '3'    
services:
 <service-name>:
   image: mysql:5.7
   container_name: <container-name>
   ports:
     - "<host-port>:<container-port>"
   environment:
     - MYSQL_ROOT_PASSWORD=<root-password>
     - MYSQL_DATABASE=<database-name>
   volumes:
     - <host-dir>:/var/lib/mysql
   networks: ['stack']
networks:
  stack:
    driver: bridge

Make sure that <host-dir> you have permission with the current user executing the docker-compose up command.

The networks is used if you have multiple services that want to connect to the database they all should consume the same network which is stack in this example

looks like a permission problem on your host.

Upvotes: 4

Related Questions