Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker MYSQL container exiting instantly with a volume

Tags:

docker

mysql

Currently learning the Docker basics and I'm having trouble when running a MYSQL image that has a Volume configured.

I'm running an up to date version of Docker Desktop for Mac on macOS 10.14.3.

When running this is works fine:

docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:8.0

But when adding a -v option it connects and then exits immediately.

docker run -d -v /Users/joebloggs/path/to/my/data:/var/lib/mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:8.0

I've tried all major versions of the official mysql image.

Here's part of a docker inspect dump:

"State": {
            "Status": "exited",
            "Running": false,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 0,
            "ExitCode": 1,
            "Error": "",
            "StartedAt": "2019-03-26T13:41:29.106885548Z",
            "FinishedAt": "2019-03-26T13:41:31.48468934Z"
        },

And the Mounts section:

"Mounts": [
            {
                "Type": "bind",
                "Source": "/Users/joebloggs/path/to/my/data",
                "Destination": "/var/lib/mysql",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
like image 448
crinklebat Avatar asked Oct 28 '25 20:10

crinklebat


1 Answers

Though according to your command, the misplaced parameters could be the cause; Use this:

$ docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:8.0
like image 169
Evans Kiptarus Kibet Avatar answered Oct 31 '25 11:10

Evans Kiptarus Kibet