0
votes

I was trying to bring up my MySql in the docker container. But, it stopped with code exited(1). Here is how I run it:

docker run --name demo-db -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -d mysql:latest --mount type=bind,source=$(pwd),target=/var/lib/mysql

Here is the log of the container

Initializing database
2018-10-12T17:50:42.694183Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2018-10-12T17:50:42.694277Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.12) initializing of server in progress as process 31
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
2018-10-12T17:51:10.497527Z 0 [ERROR] [MY-011071] [Server] unknown option '--mount'
2018-10-12T17:51:10.497543Z 0 [Warning] [MY-010952] [Server] The privilege system failed to initialize correctly. If you have upgraded your server, make sure you're executing mysql_upgrade to correct the issue.
2018-10-12T17:51:10.497551Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-10-12T17:51:14.130241Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.12)  MySQL Community Server - GPL.

Please help me...

2
I haven't used Docker in a year, but I don't recognize that --mount syntax. I remember something like -v /path/to/foo:/path/to/varwbg
@wbg with the newer versions of docker, one can use the --mount flag for standalone containersscipsycho

2 Answers

0
votes

Better answer may follow, I used to use Docker as well for MySQL but it's been a while.

Start as detached container:

docker run -v $PWD:/var/lib/mysql --name demo-db -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -d mysql:latest

Then attach to it like so:

docker run -i -t demo-db /bin/bash

Note about pwd use:

There's no need to use the pwd command, just get the shell variable $PWD. When you do foo=$(pwd) is kind of overkill, b/c you're actually running the pwd command in a sub shell to return $PWD.

0
votes

The syntax of the docker run command is basically

docker run <docker run options> IMAGE <command and arguments>

So when you run:

docker run \
  --name demo-db -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -d \
  mysql:latest \
  --mount type=bind,source=$(pwd),target=/var/lib/mysql

The --mount option is after the image name, so it's passed as an argument to the container. Move this option before mysql:latest and you'll be set.